February 28th, 2010

One-to-One Relationships

Posted by admin in A. Relational Database Basics

Relational DataBase Management Systems (RDBMS) perform more reliably than other systems because they function with an association established between common column values of two or more tables. There are three kinds of relationships:

> One-to-One
> One-to-Many
> Many-to-Many

In a one-to-one relationship, each row in Table A can have no more than one matching entry in Table B. If you are going to have a one-to-one relationship, then you probably need to include the columns from both tables in just one table. A possible exception to combining multiple one-to-one tables into one table would be if the second table’s data required higher security that would be applied only to the second table.

 

February 27th, 2010

Foreign Key

Posted by admin in A. Relational Database Basics

Foreign keys are used to associate data between tables. For instance, a foreign key of REP in the CUSTOMER_TBL points to the primary key EMPL_ID in the EMPLOYEE_TBL.

> A foreign key is one or more columns in a table whose values reference values in another table.
> A foreign key in the child table establishes a relationship to the primary key in the parent table.
> The matching foreign key and primary key can have different names.
> If this relationship is enforced, then this is called referential integrity.
> If the relationship is not enforced and there is a foreign key in a child table that does not match
the primary key of the parent table, then this is called an orphan row.
> Unlike primary keys, foreign keys can be null.
> Foreign keys are not always unique in their table.
> A foreign key can reference the primary key of the same table. For instance, the MANAGER of
an employee can reference the EMPLOYEE ID of the manager.

February 26th, 2010

Primary Key

Posted by admin in A. Relational Database Basics

Tables and columns have unique names, but rows are unnamed. Rows can not be identified by their position within the table, and the relational model looks at a table as an unordered set. Therefore, each table is required to have one or more columns as a unique primary key. It is traditional to place the primary key columns in the left-hand positions.

> A table must have one and only one primary key.
> A primary key with only one column is called a simple key.
> A primary key with two or more columns is called a composite key.
> No two rows in a table can have the same primary key.
> A primary key only includes the columns necessary for uniqueness.
> A primary key can not have an empty (null) value in any column.
> If referential integrity is enforced, a primary key can not be deleted unless all foreign keys are also deleted.

« Previous PageNext Page »