Tables Relationships PDF Print E-mail
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
IDNAME
10Sales
20Finance


In a EMPLOYEE table we would store employee IDs, Names, and the Department ID in which they work.

TABLE: EMPLOYEE
IDNAMEDEPTID
10SCOTT10
20LARRY10
30PETER20


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
 



All content is a copyright of ImplementingSAP.com