Labels

Saturday, August 13, 2011

Relational data model

relational model consists of collection of tables (relations) . table contain columns and rows. row in a table represents the relationship between the set of values.
we can say that basically table is collection of relationships(specified by rows)

note : n-tuple means a tupe with n values where tuple means a row .

main topics

keys :
definitions

super key : is a set of one or more attributes that , taken collectively , allow us to identify uniquely a tuple in the relations , so there can be many different super keys in a relation

candidate keys : a super key whose no subset is a super key ( basically minimal superkey)

primary key : a candidate key chosen by the database designer as the principle means of identifying the tuples ( example as roll_no)

foreign key : if a relation(referencing relation) contains within its attribute the primary key or even the super key of another relation(referenced relation) than that attribute is called foreign key.
a row in the referencing table cannot contain values that don't exist in the referenced table (except potentially NULL).

note : A FOREIGN KEY constraint can reference columns in tables in the same database or within the same table. These are called self-referencing tables. For example, consider an employee table that contains three columns: employee_number, employee_name, and manager_employee_number. Because the manager is also an employee, there is a foreign key relationship from the manager_employee_number column to the employee_number column.

note: The constraint enforces referential integrity by guaranteeing that changes cannot be made to data in the primary key table if those changes invalidate the link to data in the foreign key table. If an attempt is made to delete the row in a primary key table or to change a primary key value, the action will fail when the deleted or changed primary key value corresponds to a value in the FOREIGN KEY constraint of another table. To successfully change or delete a row in a FOREIGN KEY constraint, you must first either delete the foreign key data in the foreign key table or change the foreign key data in the foreign key table, which links the foreign key to different primary key data.


Relational operations :

join
Cartesian product
union
intersection
and set difference



No comments:

Post a Comment