Freetutes.com

Other Tutorials by Freetutes.com

Visual Basic - Visual Basic tutorials

VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6


You are here: Freetutes.com > Systems Analysis and Design

Relational Database Model

E.F.Codd proposed this model in the year 1970. The relational database model is the most popular data model. It is very simple and easily understandable by information systems professionals and end users.

Understanding a relational model is very simple since it is very similar to Entity Relationship Model. In ER model data is represented as entities similarly here data in represented in the form of relations that are depicted by use of two-dimensional tables.

Also attributes are represented as columns of the table. These things are discussed in detail in the following section.

The basic concept in the relational model is that of a relation. In simple language, a relation is a two-dimensional table. Table can be used to represent some entity information or some relationship between them. Even the table for an entity information and table for relationship information are similar in form. Only from the type of information given in the table can tell if the table is for entity or relationship. The entities and relationships, which we studied in the ER model, are similar to relations in this model. In relational model, tables represent all the entities and relationships identified in ER model.

Rows in the table represent records; and columns show the attributes of the entity.


Fig. 8.1 Structure of a relation in a relational model.

Fig 8.1 shows structure of a relation in a relational model.

A table exhibits certain properties. It is a column homogeneous. That is, each item in a particular column is of same type. See fig 8.2. It shows two columns for EmpNo and Name. In the EmpNo column it has only employee numbers that is a numeric quantity. Similarly in Name column it has alphabetic entries. It is not possible for EmpNo to have some non-numeric value (like alphabetic value). Similarly for Name column only alphabetic values are allowed.

EmpNo Name ....................... .......................
1001 Jason    
1002 William    
1003 Mary    
1004 Sarah    
Fig. 8.2 Columns are homogeneous

Another important property of table is each item value is atomic. That is, item can’t be further divided. For example, take a name item. It can have first name, middle name, or last name. Since these would be three different strings so they can’t be placed under one column, say Name. All the three parts are placed in three different columns. In this we can place them under, FirstName, MiddleName, and LastName. See fig 8.3.

FirstName MiddleName LastName .................
Jason Tony White .................
William Bruce Turner .................
Jack Pirate Sparrow .................
Fig. 8.3 Table columns can have atomic values

Every table must have a primary key. Primary key is some column of the table whose values are used to distinguish the different records of the table. We’ll take up primary key topic later in the session. There must be some column having distinct value in all rows by which one can identify all rows. That is, all rows should be unique. See fig. 8.4.

EmpNo EName DOJ
1001 Jason 20-Jun-2007
1002 William 12-Jul-2007
1002 William 20-Jul-2007
1010 Smith 20-Jul-2007
Fig. 8.4 Table with primary key “EmpNo” and degree “3”

In this table, EmpNo can be used as a primary key. Since it is the only column where the values are all distinct. Whereas in Ename there are two William and in DOJ column, 15-Jul- 1998 is same for three row no 1,3, and 4. If we use DOJ as primary key then there would be three records that have same DOJ so there won’t be any way to distinguish these three records. For this DOJ can’t be a primary key for this table. For similar reasons, Ename cannot be used as primary key.

Next property we are going to discuss is for ordering of rows and columns within a table. Ordering is immaterial for both rows and columns. See fig. 8.5. Table (a) and (b) represent the same table.

DName DeptID Manager
SD 1 Smith
HR 2 William
FIN 3 Jonathan
EDU 4 Jason

DName DeptID Manager
William HR 2
Mary EDU 7
Jason FIN 4
Smith SD 1
Fig. 8.5 Ordering of rows and columns in a table is immaterial

Names of columns are distinct. It is not possible to have two columns having same name in a table. Since a column specifies a attribute, having two columns with same name mean that we are specifying the same property in two columns, which is not acceptable. Total number of columns in a table specifies its degree. A table with n columns is said to have degree n. See fig. 8.1. Table represented there is of degree 3.

Domain in Relational Model

Domain is set of all possible values for an attribute. For example there is an Employee table in which there is a Designation attribute. Suppose, Designation attribute can take “PM”, “Trainee”, “AGM”, or “Developer”. Then we can say all these values make the domain for the attribute Designation. An attribute represents the use of a domain within a relation. Similarly for name attribute can take alphabetic strings. So domain for name attribute will be set of all possible valid alphabetic strings.

See Also


  

<< Previous Page | Contents | Next Page >>

   

Home | About Us | Privacy Policy | Contact Us

Copyright © Freetutes.com | All Rights Reserved