|
Written by Administrator
|
|
Tuesday, 24 March 2009 14:41 |
Tables are tied together through relationships.
Entities could have one to one, one to many, or many to many relationships with each other.
This relationship is represented in tables.
Lets take a case of EMPLOYEE and DEPARTMENT tables.
In a DEPARTMENT table we would store department IDs and Names.
TABLE: DEPARTMENT
In a EMPLOYEE table we would store employee IDs, Names, and the Department ID in which they work.
TABLE: EMPLOYEE
| ID | NAME | DEPTID |
| 10 | SCOTT | 10 |
| 20 | LARRY | 10 |
| 30 | PETER | 20 |
The DEPTID column of EMPLOYEE table is tied to the ID column of the DEPARTMENT table creating one to many relationship (through a foreign key)
Each department could be assigned to various employees.
After establishing this relationship the database would not let you insert a value in DEPTID column of EMPLOYEE table that does not exist in ID column of DEPARTMENT table. E.g. you cannot insert 30 in DEPTID because it does not exist in DEPARTMENT table.
The tables are tied to each other through relationships. This is where the name "relational database" come from.
|
|
Last Updated on Tuesday, 24 March 2009 15:04 |