<?xml version="1.0" encoding="UTF-8"?><rss version="2.0">
<channel>
<title>database</title>
<link>http://www.computersight.com/tags/database</link>
<description>New posts about database</description>
<item>
<title>Review: Three Database Design Methods</title>
<link>http://www.computersight.com/Computers/Review-Three-Database-Design-Methods.350587</link>
<description>
<![CDATA[<h3>Requirements Analysis</h3>
<p>Currently Carlos is in need of two basic tables, supplier and product. He currently has three suppliers but as his business continues to grow he expects to have more. The database needs to easily be able to add new suppliers and products without interfering with the integrity of the data or the database structure.</p>
<h3>Data Modeling</h3>
<p>Using the following diagram we can see that we will be creating two tables; suppliers and products. <img src="file:///C:/DOCUME~1/Ruti/LOCALS~1/Temp/moz-screenshot-3.jpg" alt="" /></p>
<p><img src="http://images.stanzapub.com/readers/2008/11/16/0_23.jpg" alt="" /><br />We are creating a one-to-many relationship because each supplier may have several products, but each specific product can only have one supplier. We also are going to guarantee that products have to be associated with suppliers, and suppliers have to be associated with products. A supplier is of no use without a product and a product can't come into the door without a supplier.</p>
<h3>Normalization</h3>
<p>We have reviewed the design to 3NF (Third Normal Form) and find that we are good. The Third Normal Form states that we must meet the requirements for a First Normal Form (no duplicate columns from the same table and we have separated are data into two tables), Second Normal Form (our  database is too small at this time to really worry about this), and the rules for the Third Normal Form (all of our columns are fully dependent upon the primary key.</p>
<h3>Conclusion</h3>
<p>Upon meeting the three requirements we can now safely create the database. With the design finished and compared to the rules of the Third Normal Form we can assuredly build a secure database that will grow as needed as Carlos' business grows.</p><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FComputers%2FReview-Three-Database-Design-Methods.350587"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FComputers%2FReview-Three-Database-Design-Methods.350587" border="0"/></a>]]></description>
<pubDate>Wed, 19 Nov 2008 02:22:18 PST</pubDate></item>
<item>
<title>Creating a Database Mission Statement</title>
<link>http://www.computersight.com/Computers/Creating-a-Database-Mission-Statement.349527</link>
<description>
<![CDATA[<p>Questions for Carlos (Owner)<br /> To get a better feel for what our mission statement and mission objectives are I have decided to ask Fernando the following questions:<br />1.	How do you currently store data?<br />2.	How would you describe your business?<br />3.	What kind of customer base do you have?<br />4.	What do you do with your customer data?<br />5.	Do you need to keep track of employee information?<br />6.	What are you hoping this database can do for you?<br />Questions for Carlita (Counter Person)<br /> Carlita, too, has input on the day-to-day practices of the shop. We have decided to ask her the following questions:<br />1.	What type of work do you perform on a daily basis?<br />2.	What data do you keep track of?<br />3.	What would make dealing with customers easier?<br />4.	How much computer experience do you have?<br />5.	What are you hoping this database can do for you?<br />Mission Statement<br /> The purpose of the Carlos' Bike Shop database is to maintain data and to use that data to increase efficiency with everyday functions and customer relations.<br />Mission Objectives<br /> The following is a list of mission objectives that we feel will be needed for the completion of this phase of the design process.<br />1.	We need to keep track of employee information.<br />2.	We need to keep track of customer information.<br />3.	We need to keep track of all sales orders.<br />4.	We need detailed information on suppliers.<br />5.	We need detailed information on products.<br />Conclusion<br /> With the above mission statements defined we can come to several conclusions on what this database will need to do. We will need to keep track of employees contact information and hours, customer addresses and products that they have purchased, inventory control and automated product ordering, complete supplier information, and even an automated mailing list. Through these we can make Carlos' Bike Shop more successful and easier to manage.</p>
<p>References<br />Hernandez, M. (2003). Database Design for Mere Mortals Second Edition. Boston, MA: Addison-Wesley.</p><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FComputers%2FCreating-a-Database-Mission-Statement.349527"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FComputers%2FCreating-a-Database-Mission-Statement.349527" border="0"/></a>]]></description>
<pubDate>Mon, 17 Nov 2008 04:58:09 PST</pubDate></item>
<item>
<title>Relational DBMS</title>
<link>http://www.computersight.com/Computers/Relational-DBMS.291031</link>
<description>
<![CDATA[<p>The relational model presents an orderly, predictable and intuitive approach to organizing, manipulating and viewing data.</p>
<h3>RDBMS Terminology</h3>
<p>Relational data consists of relations. A relation (or relational table) is a two dimensional table with special properties. A relational table consists of a set of named columns and an arbitrary number of rows. The columns are called as attributes and rows are called as tuples. Each attribute is associated with a domain. A domain is a set of values that may appear in one or more columns.</p>
<h3>Properties of Relational Data Structures</h3>
<p>Relational tables have six properties, which must be satisfied for any table to be classified as relational. These are:</p>
<ol>
<li>Entries of attributes are single valued: Entry in every row and column position in a table must be single valued. This means columns do not contain repeating groups.</li>
<li>Entries of attribute are of the same kind: Entries in a column must be of same kind. A column supposed to store salary of an employee should not store commission.</li>
<li>No two rows are identical: Each row should be unique. This uniqueness is ensured by the values in a specific set of columns called the primary key.</li>
<li>The order of attributes is unimportant: There is no significance attached to order in which columns are stored in the table. A user can retrieve columns in any order.</li>
<li>The order of rows is unimportant: There is no significance attached to the order in which rows are stored in the table. A user can retrieve rows in any order.</li>
<li>Every column can be uniquely identified: Each column is identified by its name and not its position. A column name should be unique in the table.</li>
</ol><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FComputers%2FRelational-DBMS.291031"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FComputers%2FRelational-DBMS.291031" border="0"/></a>]]></description>
<pubDate>Fri, 10 Oct 2008 02:59:00 PST</pubDate></item>
<item>
<title>Introduction to Database</title>
<link>http://www.computersight.com/Computers/Introduction-to-Database.291007</link>
<description>
<![CDATA[<p>A set of inter-related data is known as database and the software that manages it is known as database management system or DBMS. Hence DBMS can be described as &amp;ldquo;a computer-based record keeping system which consists of software for processing a collection of interrelated data&amp;rdquo;. A set of structures and relationships that meet a specific need is called as a schema.<br /><br />The database is centrally managed by a person known as the database administrator or the DBA. The DBA initially studies the System and accordingly decides the types of data to be used, then the structures to be used to hold the data and the interrelationships between the data structures. He then defines data to the DBMS. The DBA also ensures the security of the database. The DBA usually controls access to the data through the user codes and passwords and by restricting the views or operations that the user can perform on the database.</p>
<h3>Characteristics of DBMS</h3>
<p>Control of data redundancy: When the same data is stored in a number of files it brings in data redundancy. In such cases, if the data is changed at one place, the change has to be duplicated in each of the files.<br />The main disadvantages of data redundancy are:<br />1)Storage space gets wasted.<br />2)Processing time may be wasted as more data is to be handled.<br />3)Inconsistencies may creep in.<br />4)DBMS help in removing redundancies by providing means of integration.<br /><br />Sharing of data: DBMS allow many applications to share the data.<br /><br />Maintenance of Integrity: Integrity to data refers to correctness, consistency and the interrelationship of data with respect to the application that uses the data. Some of the aspects of data integrity are:<br />1)Many data items can only take a restricted set of values.<br />2)Certain field values are not to be duplicated across records. Such restrictions, called primary key constraints can be defined to the DBMS.<br />3)Data integrity which defines the relationships between files is called referential integrity rules, which can also be specified to the DBMS.<br /><br />Support for Transaction Control and Recovery: Multiple changes to the database can be clubbed together as a single &amp;lsquo;logical transaction&amp;rsquo;. The DBMS will ensure that the updates take place physically only when the logical transaction is complete.</p>
<p>Data Independence: In conventional file based applications, programs need to know the data organization and access technique to be able to access the data. This means that if you make any change in the way the data is organized you will also have to take care to make changes to the application programs that apply to the data. In DBMS, the application programs are transparent to the physical organization and access techniques.<br /><br />Availability of Productivity tools: Tools like query language, screen and report painter and other 4GL tools are available. These tools can be utilized by the end-users to query, print reports etc. SQL is one such language, which is emerging as standard.<br /><br />Control over Security: DBMS provide tools by which the DBA can ensure security of the database.<br /><br />Hardware Independence: Most DBMS are available across hardware platforms and operating systems. Thus the application programs need not be changed or rewritten when the hardware platform or operating system is changed or upgraded.</p>
<h3>The DBMS Model</h3>
<p>The range of data structures supported and the availability of data handling language depend on the model of DBMS is based. The models are:<br />1) The hierarchical model.<br />2) The network model.<br />3) The relational model.<br /><br />The hierarchical model: In this parent can have many children. A child cannot have more than one parent and no child can exist without its parent.<br /><br />The Network model: In this there are no restrictions on the number of parents. A record type can have any number of parent and child record types. It is more complex than the hierarchical model because of links. It can represent any structure designed in hierarchical model, and so is a superset of the hierarchical model.<br /><br />Relational Model: Because of lack of linkages relational model is easier to understand and implement.</p><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FComputers%2FIntroduction-to-Database.291007"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FComputers%2FIntroduction-to-Database.291007" border="0"/></a>]]></description>
<pubDate>Fri, 10 Oct 2008 02:46:51 PST</pubDate></item>
<item>
<title>SQL and Databases</title>
<link>http://www.computersight.com/Programming/SQL-and-Databases.289641</link>
<description>
<![CDATA[<h3>SQ</h3>
<p>SQL can be expanded as Structured Query Language. It is used to create, manipulate and delete data in a database. This language facilitates very easy database interactions. SQL statements are simple and easy to execute.</p>
<h3>Query</h3>
<p>Query is a statement which is used to manipulate data available in a database, granting users roles and permissions, creating new databases, creating new tables, deleting table values etc.</p>
<h3>Creating New Tables</h3>
<p>Using a single statement we can able to create a new table. The following query when executed creates a new table.</p>
<h4>Syntax</h4>
<p>Create table TABLE_NAME (VARIABLES)</p>
<h4>Example</h4>
<p>Create table employee (name VARCHAR (20), num NUMBER (5))</p>
<p>The above query creates employee table with name and num fields. It has the ability to store number of names with their employee numbers.</p>
<h3>Inserting Values to New Table</h3>
<p>Insert statement is used to insert a new record into the table. The Insert statement has the following syntax.</p>
<h4>Syntax</h4>
<p>Insert into TABLE_NAME (VALUES)</p>
<h4>Example</h4>
<p>Insert into employee ('xxx', 30)</p>
<h3>Modifying Values in a Table</h3>
<p>We can able to modify the values available in a table by using the update query. The update query has the following syntax.</p>
<h4>Syntax</h4>
<p>Update TABLE_NAME set VARIABLE = VALUE where CONDITION</p>
<h4>Example</h4>
<p>Update employee set name='xyz' where num=30</p>
<h3>Selecting a Particular Record</h3>
<p>A particular record can be fetched from the table. It can be evaluated by using the select query.</p>
<h4>Syntax</h4>
<p>Select VARIABLES from TABLE_NAME</p>
<h4>Example</h4>
<p>Select name, num from employee where num=30</p>
<p>The above query when executed checks the database for num=30 if the condition is satisfied then the particular query will be fetched from the table.</p>
<h3>Deleting a Record from the Table</h3>
<p>A particular record can be deleted from the table using the following query. Using the delete statement we can able to delete a single record or a group of record having a same attribute.</p>
<h4>Syntax</h4>
<p>Delete from TABLE_NAME where CONDITION</p>
<h4>Example</h4>
<p>Delete from employee where num=30</p>
<p>This article describes the basic SQL operations such as creating a table, selecting values from the table, inserting a new record, modifying an existing record, deleting a record. All these queries form the basis for the database operations.</p><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FSQL-and-Databases.289641"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FSQL-and-Databases.289641" border="0"/></a>]]></description>
<pubDate>Wed, 08 Oct 2008 14:45:21 PST</pubDate></item>
<item>
<title>PHP Tutorial: Printing on the Screen</title>
<link>http://www.computersight.com/Programming/PHP/PHP-Tutorial-Printing-on-the-Screen.112786</link>
<description>
<![CDATA[<p>PHP is a script language commonly used by webmasters to design dynamic websites. Unlike HTML which has static content, PHP has dynamic content because of user interaction. Today, most of the qualified websites are designed by PHP or CGI.</p>
 
<p>PHP scripts embedded into the HTML codes. When someone checks the source code of the page, he doesn't get anything about PHP scripts. He only learns the HTML part of coding. This article is an introduction to PHP scripting language. One can find useful information and have enough knowledge after reading my PHP tutorial series. Without delay, I would like to start my script creation step by step.</p>
 
<p>Before starting, you should know that you have to set up PHP installations into your computer. Such installations are PHP itself, Phpmyadmin interface, Mysql database and Apache Server. Without these, your scripts are nothing since they are not compiled by your computer.</p>
 
<h3>Step 1:</h3>
 
<p>To write PHP scripts, we need a place. That place is a simple text editor. You are free to choose your text editor. I prefer  to use Notepad. There are other alternatives like Editplus or Elfima. If your operating system is not Windows but Linux, you can place your code into Vi editor or Pico. I have never tried but I think you can use Dreamveawer, Hotdog or Frontpage.</p>
 
<p>In your text editor, open an new file and save it as &amp;ldquo;myfirst.php&amp;rdquo; or &amp;ldquo;myfirst.html&amp;rdquo; . I choose the name of file as &amp;ldquo;myfirst&amp;rdquo; but you are free to choose anything.</p>
 
<h3>Step 2:</h3>
 
<p>I have told you before that PHP scripts are embedded into HTML codes. So, first of all we will write HTML codes. The basic codes are HTML, TITLE, HEAD and BODY. It can be written by lowercase letters as well. This part is not important.</p>
 
<p><img src="http://images.stanzapub.com/readers/computersight/2008/04/22/149028_0.jpg" alt="" /></p>
 
<p><strong>Step 3: </strong>All PHP scripts start with &amp;ldquo;  &amp;rdquo;. Only the part between two  is compiled by server and evaluated as output.To print characters on the screen, standart output functions of PHP are used. Those are &amp;ldquo; print &amp;rdquo; and &amp;ldquo; echo &amp;rdquo;. In some circumstances, &amp;rdquo; printf &amp;rdquo; is used too.</p>
 
<p>The format of printing:</p>
 <ol> 
<li> print  ( &amp;ldquo; your output &amp;rdquo; ) ;</li>
 
<li> print   &amp;ldquo; your output &amp;rdquo;  ;</li>
 
<li> echo &amp;ldquo; your output &amp;rdquo;  ;</li>
 
<li> echo ( &amp;ldquo; your outpu t&amp;rdquo; ) ; </li>
 </ol> 
<p>If you don't use any white space characters, the strings are written without any separation. For example if you write this code;</p>
 
<ul>
<li>Print ( &amp;ldquo; Word1 &amp;rdquo; ) ;</li>
 
<li>Print ( &amp;ldquo; Word2 &amp;rdquo; ) ;</li>
 
</ul>
<p>It will be outputted as Word1Word2.</p>
 
<p>To remove this fault,white space characters are used. In PHP code part, between print functions, we place &amp;lt; br &amp;gt; code.</p>
 
<p>Example: To be more understandable,I will write a simple PHP script. Output will be the name of my favorite Triond writers.</p>
 
<p><img src="http://images.stanzapub.com/readers/computersight/2008/04/22/149028_1.jpg" alt="" /></p>
 
<p>To see the output,<a href="http://learnphp.awardspace.biz/" target="_blank"> Click here.</a></p><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FPHP%2FPHP-Tutorial-Printing-on-the-Screen.112786"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FPHP%2FPHP-Tutorial-Printing-on-the-Screen.112786" border="0"/></a>]]></description>
<pubDate>Tue, 22 Apr 2008 06:42:32 PST</pubDate></item>
<item>
<title>Microsoft Access Database 2: Creating a Table</title>
<link>http://www.computersight.com/Software/Microsoft-Office-Suite/Microsoft-Access-Database-2-Creating-a-Table.76012</link>
<description>
<![CDATA[<h3>Creating A New Database</h3>
 
<p>Open Microsoft Access.</p>
 
<p>On the task pane on the right-hand side of your Access screen, click on Blank Database</p>
 
<p><img src="http://images.stanzapub.com/readers/computersight/2008/01/21/102813_0.jpg" alt="" /></p>
 
<p><img src="http://images.stanzapub.com/readers/computersight/2008/01/21/102813_1.jpg" alt="" /></p>
<p><strong>IMPORTANT:</strong> You must enter your own filename.  If you do not, the program will give its own default name - it will start with db1 and next to db2 and so on.  Obviously these file names mean nothing, so make sure that you give your database a name that makes sense.</p>
 
<p>Select the Create button.</p>
 
<p>You have now created your database but at the moment it has no structure and contains no data.  To set up these things we must create a table.</p>
 
<h3>CREATING A TABLE</h3>
 
<h3>Designing The Table's Structure</h3>
 
<p>Before we can enter data into a database, we must:</p>
 <ol> 
<li> Create a <strong>TABLE</strong> to take the data. </li>
 
<li> Define the table's <strong>FIELDS</strong> - that is, the categories of information required in this database. </li>
 
<li> Give each field a <strong>FIELD NAME</strong>. </li>
 
<li> Specify the <strong>DATA TYPE</strong> that we wish to enter into each field (i.e. whether the data in that field will be Text, Number, Currency, Date/Time etc.) </li>
 </ol> 
<ul>
<li> <strong>It is best to</strong> <strong>do this planning on paper</strong> before you start putting it into Access.  In this handbook the planning has already been done for you and you just have to follow the instructions. </li>
 
</ul>
<h3>The Database Window</h3>
 
<p>The Database Window contains a number of options for different sorts of <strong>database</strong> <strong>OBJECTS</strong>: Tables, Queries, Forms, Reports and more.</p>
 
<p><img src="http://images.stanzapub.com/readers/computersight/2008/01/21/102813_2.jpg" alt="" /></p>
 
<p>To design a table we need to select <strong>Tables</strong> as above.  There are three different ways of creating a new table.  We are going to use <strong>Create table in Design view </strong>so click on it.</p>
 
<p>The Design view appears as a blank grid with 3 columns headed <strong>Field Name</strong>, <strong>Data Type</strong> and <strong>Description</strong>.  You are going to use this grid to design your table.</p>
 
<p><img src="http://images.stanzapub.com/readers/computersight/2008/01/21/102813_3.jpg" alt="" /></p>
 
<p>Enter the word <strong>TITLE</strong> as the first <strong>Field Name</strong> in the top left-hand corner.  Press the <strong>Tab</strong> key to move to the second column and note that the Data Type <strong>&amp;ldquo;Text&amp;rdquo;</strong> appears.  Don't change this because the data type of film titles must be Text.</p>
 
<p>Press the Tab key twice to move down to the beginning of the second row.</p>
 
<p>Enter the next Field Name, which is <strong>STAR</strong>.  Press the <strong>Tab</strong> key to move to the second column and again leave the Data Type <strong>&amp;ldquo;Text&amp;rdquo;</strong>.</p>
 
<p>Continue the same process by copying the details in the following <strong>Table Design</strong> box until you can see all five field names and their data type &amp;ldquo;Text&amp;rdquo;.</p>
 
<p>Check your own version against this next graphic:</p>
 
<p><img src="http://images.stanzapub.com/readers/computersight/2008/01/21/102813_4.jpg" alt="" /></p>
 
<h3>Changing Data Types</h3>
 
<p>Some of the above fields are of the wrong Data Type so we must make some changes.</p>
 
<p>First of all, we must change the Data Type of the <strong>DATE</strong> field.  We shall put numeric data into that field (e.g. 1941 or 1980) so the Data Type must be <strong>NUMBER</strong>.</p>
 
<p>Click in the Data Type column in the same row as the field name DATE.  Then click on the drop-down button which has appeared in the right-hand side of the box.</p>
 
<p>This produces a list of possible data types.</p>
 
<p><img src="http://images.stanzapub.com/readers/computersight/2008/01/21/102813_5.jpg" alt="" /></p>
 
<p>Now change the Data Type of the <strong>PRICE</strong> field to <strong>Currency</strong> in the same way and press the Tab key twice.</p>
 
<p><img src="http://images.stanzapub.com/readers/computersight/2008/01/21/102813_6.jpg" alt="" /></p>
 
<p>We could also use the Description column to include information about the fields that would be helpful to the persons who use the database. However, in this exercise we shall leave that column blank.</p>
 
<h3>Saving The Table</h3>
 
<p>As with other Microsoft programs, go to <strong>File</strong> and <strong>Save</strong>.  Change the table name in the Save As box by calling it Table 1 followed by your name.  For example, <strong>my table</strong> would now be called <strong>Table 1 - Ray</strong>.</p>
 
<p><img src="http://images.stanzapub.com/readers/computersight/2008/01/21/102813_7.jpg" alt="" /></p>
 
<p>Click <strong>OK</strong>.  This will produce a Dialogue Box asking you whether you want to create a <strong>PRIMARY KEY</strong>.</p>
 
<p><img src="http://images.stanzapub.com/readers/computersight/2008/01/21/102813_8.jpg" alt="" /></p>
 
<p>Click on <strong>NO</strong> because at the moment it isn't necessary to use a primary key.</p>
 
<h3>Closing The Table</h3>
 
<p>The table has been saved and you have completed the design of a simple database.</p>
 
<p>Close the table by clicking on the <strong>X</strong> in the top right-hand corner of the design box.</p>
 
<p>This takes you back to the <strong>Database Window</strong> - close it in the same way.</p>
 
<h3>NEXT: ENTERING DATA</h3><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FSoftware%2FMicrosoft-Office-Suite%2FMicrosoft-Access-Database-2-Creating-a-Table.76012"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FSoftware%2FMicrosoft-Office-Suite%2FMicrosoft-Access-Database-2-Creating-a-Table.76012" border="0"/></a>]]></description>
<pubDate>Mon, 21 Jan 2008 04:23:38 PST</pubDate></item>
<item>
<title>Microsoft Access Database 1: What is a Database</title>
<link>http://www.computersight.com/Software/Microsoft-Office-Suite/Microsoft-Access-Database-1-What-is-a-Database.75923</link>
<description>
<![CDATA[<p>First of all, I have to make certain assumptions about you as a learner.  I assume, for example, that:</p>
 
<ul>
<li> You already have experience of using a version of Microsoft Windows. <br /></li>
 
<li>You have previously used another software package e.g. Word or Excel. </li>
 
</ul>
<h3>What Is A Database?</h3>
 
<p>An electronic database is a collection of data (information) on a particular topic.  It is organised and stored in such a way that data can be retrieved easily and quickly when we ask the database specific questions.  As you will see later, it is much more flexible than &amp;ldquo;manual&amp;rdquo; systems which use paper and filing cabinets.</p>
 
<h4>Here are a few examples of database topics:</h4>
 
<ul>
<li> Personal and financial details of bank customers <br /></li>
 
<li>The stock held by a supermarket</li>
 
<li>Details of sports club members</li>
 
<li>A catalogue of all your music CDs</li>
 
</ul>
<p>When we create a new database, it is very important to plan carefully the structure
that we need to suit the kind of data we want to store and retrieve.</p>
 
<p>We shall design our database as a TABLE.  Before we do so, you should know the following terms:</p>
 
<h3>DATABASE</h3>
 
<p>A collection of data on one particular topic.</p>
 
<p>e.g. a database in a video shop, giving details of all the videos available for sale.</p>
 
<p>Each new database must have its own unique FILENAME.</p>
 
<h3>TABLE</h3>
 
<p>A grid consisting of columns and rows.</p>
 
<p>Each Table must have its own TABLE NAME.</p>
 
<p>One database may have a number of tables in it.</p>
 
<p>A table is often referred to by professional database designers as an ENTITY.  Although these pages will still refer to tables as tables, be aware of this term!</p>
 
<h3>FIELD</h3>
 
<p>A column of the Table, containing one category of data.</p>
 
<p>For example, it can be the Title of a film or the name of its Director or the Price of the video.</p>
 
<p>Each field must have a heading called a FIELD NAME.</p>
 
<p>A Table may have any number of Fields.</p>
 
<h3>DATA TYPE</h3>
 
<p>The kind of Data contained in a Field.</p>
 
<p>The data types may be Text, Number or Currency.</p>
 
<p>Each Field must contain a single Data Type.</p>
 
<h3>RECORD</h3>
 
<p>A row of the Table, in which we put the actual data</p>
 
<p>For example, this could be the details of one film in all the Fields (columns)</p>
 
<p>Each record is unique.  Although some records may have some data in common (e.g. two films may have the same Director), no two records will have the same data in all fields.</p><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FSoftware%2FMicrosoft-Office-Suite%2FMicrosoft-Access-Database-1-What-is-a-Database.75923"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FSoftware%2FMicrosoft-Office-Suite%2FMicrosoft-Access-Database-1-What-is-a-Database.75923" border="0"/></a>]]></description>
<pubDate>Sun, 20 Jan 2008 11:49:48 PST</pubDate></item>
<item>
<title>The Phantom Problem</title>
<link>http://www.computersight.com/Programming/The-Phantom-Problem.39888</link>
<description>
<![CDATA[<p>The Phantom Problem can occur in database management systems in particular scenarios involving concurrency, and can cause unexpected and faulty behavior if it's not handled correctly. Let me first begin with an example.</p>


 <h3>Finding the Oldest</h3>


 <p>Let's say that transaction T1 is accessing a relation Employee(<STRONG>eid</STRONG>, name, seclevel, age), and is looking for the oldest employee with security level (seclevel) of 1, and the oldest employee with seclevel = 2. We assume that the DBMS is using page locking. T1 identifies and locks all pages containing entries where seclevel = 1, the oldest of which is 46.</p>


 <p>At this point, a transaction T2 starts executing an update, as a new employee has been hired. It creates an exclusive lock on a page that T1 is not reading, as it doesn't contain any entries with seclevel = 1. Then it inserts the new entry, where the age is 54. Then it removes the oldest employee with seclevel = 2, whose age is 65, and commits.</p>


 <p>At this point, T1 locks all pages containing entries with seclevel = 2, finds the oldest, who is 62, and returns the results.</p>


 <h3>What happened here?</h3>


 <p>The result of these interleaved operations is that T1 returns the ages 46 and 62. If the transactions had been executed serially, the result would have been either 46 and 65 (T1 first, then T2) or 54 and 62 (T2 first, then T1).</p>

 <p>As you can see, the result is not identical to any serial execution of the two transactions, which a robust DBMS should guarantee.</p>

 <h3>A Solution</h3>

 <p>To find a cure for this oddity, we can take one of two approaches, depending of the structure of the DB.</p>

 <p><ul>
  <li> If the DB has an index on the seclevel field, T1 must identify the page containing the index, and lock the ones that contain an entry with seclevel = 1. If no such entry exists, it must lock the page where there would be an entry with seclevel = 1, if one were created. This is called index locking, and prevents creation of a new entry, as the index page for the new entry is locked.</li>
  <li> If there is no index on the seclevel field, T1 must lock all existing pages for reading, as well as ensuring that no new page can be created. Thus no new entry can be created.  </li>
 </ul></p>

 <p>Both techniques ensures no modification of existing entries with seclevel = 1, and that no new entry of this type can be inserted.</p>

 <h3>Conclusion</h3>

 <p>The two possible solutions available for this issue generates new requirements for the DBMS. For instance, the DBMS must let T1 be able to identify the correct index page to lock, and it must let T1 prevent creation of new pages.</p>

 <p>This only demonstrates a tiny piece of the massive complexity of robust and consistent DBMS.</p><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FThe-Phantom-Problem.39888"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FThe-Phantom-Problem.39888" border="0"/></a>]]></description>
<pubDate>Wed, 06 Jun 2007 07:49:56 PST</pubDate></item>
<item>
<title>Normal Forms of Relations</title>
<link>http://www.computersight.com/Programming/Normal-Forms-of-Relations.39890</link>
<description>
<![CDATA[<p>Given a relation schema, we need a way to decide whether or not it is a good design, or if we need to decompose it into smaller relations. To help guide us through these decisions, normal forms were defined. If we can say that a relation is of a certain normal form, we know that certain problems cannot arise.</p>
 <h3>First Normal Form</h3>
 <p>A relation is said to be in First Normal Form (1NF) if and only if each attribute of the relation is atomic. This means that each columns (visualizing the relation as a table) only contains a single value and that each row contains the same columns.</p>
 <p>Violation of 1NF is commonly achieved by storing lists of data in the same field (a comma-separated list for example), which will make it difficult to write queries comparing the separate elements in the list to other entries' elements.</p>

 <p><table cellpadding="0" border="1" rules="all">
  
   
   
  
  
   <tr>
    <td><u>Id</u></td>
    <td>Indexes</td>
   </tr>
   <tr>
    <td>0</td>
    <td>0,4,6</td>
   </tr>
   <tr>
    <td>1</td>
    <td>3,4</td>
   </tr>
  
 </table></p>
 <p>Also, by storing the list as separate fields containing the same data, there is also a breach of 1NF.</p>


 <p><table cellpadding="0" border="1" rules="all">
  
   
   
   
   
  
  
   <tr>
    <td><u>Id</u></td>
    <td>Index (0)</td>
    <td>Index(1)</td>
    <td>Index(2)</td>
   </tr>
   <tr>
    <td>0</td>
    <td>0</td>
    <td>4</td>
    <td>6</td>
   </tr>
   <tr>
    <td>1</td>
    <td>3</td>
    <td>4</td>
    <td></td>
   </tr>
  
 </table></p>

 <p>The desired solution in this case would be:</p>

 <p><table cellpadding="0" border="1" rules="all">
  
   
   
  
  
   <tr>
    <td>Id</td>
    <td>Index</td>
   </tr>
   <tr>
    <td>0</td>
    <td>0</td>
   </tr>
   <tr>
    <td>0</td>
    <td>4</td>
   </tr>
   <tr>
    <td>0</td>
    <td>6</td>
   </tr>
   <tr>
    <td>1</td>
    <td>3</td>
   </tr>
   <tr>
    <td>1</td>
    <td>4</td>
   </tr>
  
 </table></p>

 <h3>Second Normal Form</h3>

 <p>A 1NF relation is in Second Normal Form (2NF) if and only if all non-key attributes are dependent on the whole of the candidate key, and not just a part of it.</p>

 <p>A side-effect of this definition is that all relations in 1NF that has no composite candidate keys are automatically in 2NF.</p>

 <p>Given the following relation:</p>

 <p><table cellpadding="0" border="1" rules="all">
  
   
   
   
  
  
   <tr>
    <td><u>Id</u></td>
    <td><u>Interest</u></td>
    <td>Age</td>
   </tr>
   <tr>
    <td>0</td>
    <td>Music</td>
    <td>18</td>
   </tr>
   <tr>
    <td>0</td>
    <td>Football</td>
    <td>18</td>
   </tr>
   <tr>
    <td>1</td>
    <td>Stamps</td>
    <td>46</td>
   </tr>
  
 </table></p>

 <p>As you can see, the non-key attribute <STRONG>Age</STRONG> is dependent only on part of the key, namely <STRONG>Id</STRONG>, therefore, this relation is not 2NF. A conversion to make it 2NF is as follows:</p>


 <p><table cellpadding="0" border="1" rules="all">
  
   
   
  
  
   <tr>
    <td><u>Id</u></td>
    <td><u>Interest</u></td>
   </tr>
   <tr>
    <td>0</td>
    <td>Music</td>
   </tr>
   <tr>
    <td>0</td>
    <td>Football</td>
   </tr>
   <tr>
    <td>1</td>
    <td>Stamps</td>
   </tr>
  
 </table></p>
 
 <p><table cellpadding="0" border="1" rules="all">
  
   
   
  
  
   <tr>
    <td><u>Id</u></td>
    <td>Age</td>
   </tr>
   <tr>
    <td>0</td>
    <td>18</td>
   </tr>
   <tr>
    <td>1</td>
    <td>46</td>
   </tr>
  
 </table></p>


 <h3>An Alternative Notation</h3>

 <p>To make all this easier to work with, we will introduce a more clear notation that gives us only the necessary information. In the case above we could have written it as follows:</p>

 <p>R(ABC), F = { A->C, A->B, B->A }, where A = Id, B = Interest and C = Age. One could use the actual names instead of letters, but I find single letters easier to read and understand.</p>

 <p>R(ABC) denotes the relation and its attributes, and F denotes the dependencies, where C depends on A, and A and B depends on each other. Analyzing the dependencies will give us the candidate keys, in this case it's only AB, as both A and B is needed to fully identify the entry, but C is not needed, as no other attribute depends on it (note that a different attribute must imply C, or C would be needed as well).</p>

 <p>Transforming these into 2NF results in the following:</p>

 <p>R(AB), F = { A->B, B->A }, which gives the key AB.</p>

 <p>R(AC), F = { A->C }, which gives the key A.</p>

 <h3>Third Normal Form</h3>

 <p>A 2NF relation is in Third Normal Form (3NF) if and only if for all the non-trivial functional dependencies X->A, one of the following is true:</p>

 <p><ul>
  <li> X is a superkey (X identifies the whole entry  unambiguously)</li>

  <li> A is a prime attribute (i.e. A is part of a candidate key)  </li>

 </ul></p>

 <p>To violate 3NF, consider the following relation:</p>
 <p>R(ABCD), F = { AB->CD, C->D }, where the key would be AB.</p>

 <p>This is a breach of 3NF, as the non-prime attribute D can be identified by C, which is not a superkey. A decomposed relation in 3NF would be:</p>

 <p><ul><li>R(ABC), F = { AB->C }, where the key would be AB.</li>

 <li>R(CD), F = { C->D }, where the key would be C.</li></ul></p>

 <p>Most relations in 3NF are not affected by update, insertion and deletion anomalies, such as updating of redundant data. For instance, if we look at the non-3NF example, when D changes, the CD-pair can be represented multiple places, and unless all of them are updated correctly, an inconsistency will occur. In the 3NF version, this problem will not occur, as the data is only present at one place.</p>

 <h3>Boyce-Codd Normal Form</h3>

 <p>This is a slightly more strict version of 3NF, and imposes just one other requirement. Namely, for every non-trivial functional dependency X->A, X is a candidate key.</p>
 <p>An example of a 3NF relation that's not BCNF could be the following (using a table to suggest the actual relations):</p>

 <p><table cellpadding="0" border="1" rules="all">
  
   
   
   
   
  
  
   <tr>
    <td>A=EmployeeID</td>
    <td>B=EmployeeSSN</td>
    <td>C=CustomerID</td>
    <td>D=CustomerSSN</td>
   </tr>
  
 </table></p>

 <p>A and B are related, and C and D are related. The relation is supposed to model which employee handles which customer in a company. Since both the IDs and the Social Security Numbers are valid identifiers of both customer and employee, there is an implication between all single attributes, as follows:</p>

 <p>R(ABCD), F = { A->B, B->A, C->D, D->C, A->C, C->A, B->D, D->B, etc.}</p>

 <p>But the candidate keys are always two of the attributes (one that identifies the employee, and one that identifies the customer).</p>

 <p>As you can see, the there are dependencies on attributes that are not the whole candidate key, therefore it violates BCNF.</p>

 <h3>Conclusion</h3>

 <p>There are even higher normal forms in use (4NF and 5NF), but I will not cover them here. I'm certain a search on Google will give you some information.</p>

 <p>Using normal forms is a very efficient and safe way to model and decompose relations that are not prone to update errors and inconsistencies, and an understanding of these are very beneficial and can save a lot of time in error tracking.</p><a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FNormal-Forms-of-Relations.39890"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FNormal-Forms-of-Relations.39890" border="0"/></a>]]></description>
<pubDate>Wed, 06 Jun 2007 06:35:18 PST</pubDate></item>
</channel>
</rss>
