Monday, 17 September 2012

M1 corrected

Referential integrity:
Referential integrity is a tool that allows you to control relations between records in related tables. Referential integrity is defined as a relationship of two tables. The table that has the referential integrity rule specified is called inferior table. Table specified in the integrity constraint is called superior table. A column or a group of columns is set in both tables as a key. Rules of referential integrity guarantee, that for each record in the inferior table whose key is not NULL there exists a record in the superior table with the same key. The key in the superior table has to be a unique key, the key in the inferior table has to be some key. Referential integrity does the following when manipulating data:
1.When adding a record into the inferior table  existence of the same key in the superior table is checked.
2.When deleting a value in the superior value, existence of the same key in the inferior table is checked.

Primary keys and foreign keys:
A primary key is a constraint defined on a relational database table that prevents users from entering duplicate records into the table. The purpose or the function of a primary key, in reference to one’s database, is to facilitate the implementation of a relationship between two tables in a relational database. It is the target in which a foreign key can reference. The foreign key is a unique field in a database that another table will use to access information, such as a "look up" table. For instance, Table 1 might consist of names and addresses, keyed in by a unique identifier. Table 2 might consist of city/state names, keyed in by the telephone area code. The area code would be the foreign key, and table 1 would have a telephone field, including the area code. The area code in table 2 ties in to the area code in table 2 (the look up table), tied together by the area code to return the city and state from which the phone number originates. This area code in table 2 is a foreign field of table 2.
Primary Key: It will not allow "Null values" and "Duplicate values"
Foreign Key: It will allow "Null values" and "Duplicate values" and it refers to a primary key in another table.

Relationships

One to one relationships; each primary key will relate specifically to one or none record in the table
One to many; This primary key will relate to one, none or more than one records in that table
Many to many; Each key in both tables can relate to more than one or any number of records.

2 comments:

  1. Add examples of the different relationship types and this will be fine.

    ReplyDelete
  2. Good work. Not sure about the caps though.

    ReplyDelete