250 likes | 513 Views
Relational Database & Relational Algebra. Chapter 5, Elmasri & Navathe (2000). Tuples, Domains. Ordering. Usually the tuples must be ordered It may not be ordered if the attributes are explicit in the tuples. Relational Database Schema. Relational Database State. Naming of attributes.
E N D
Relational Database & Relational Algebra Chapter 5, Elmasri & Navathe (2000)
Ordering • Usually the tuples must be ordered • It may not be ordered if the attributes are explicit in the tuples
Naming of attributes • Same names, same thing • Same names, different things • Different names, same thing
Entity integrity constraints • Primary key can not be null
Referential Integrity Constrains • Maintain consistency between 2 tuples relations • Example: • Every DNO (Dept Number) on each EMPLOYEE must match one of the actual department number • The DNUMBER attribute of DEPARTMENT is the foreign key
Foreign Key • Can also refer to its own relation • Example: SSN of Supervisor • Also called state constraints • Transition constraints?
Database update constraints • Insert: • No null on primary key, no same primary key, no foreign key • Delete: • when it is referred by another tuple, you can not delete it • Update • No foreign key
Select Project Rename Union, Intersection, Difference Join Equijoin Natural Join Cartesian Product Division Aggregate Outer Join Relational Algebra
JOIN • DEPT_MGR DEPARTMENT |X|MGRSSN=SSN EMPLOYEE • RESULT πDNAME, LNAME, FNAME (DEPT_MGR)
NATURAL JOIN • When the attribute of the tuples are the same
DIVISIOIN • SMITH LNAME=‘Smith’ (EMPLOYEE) • SMITH_PNOS πPNOS(WORKS_ON |X| ESSN=SSN SMITH) • SSN_PNOS πESSN, PNO(WORKS_ON) • ??? SSN_PNOS SMITH_PNOS
LEFT OUTER JOIN • TEMP EMPLOYEE ]X| SSN=MGRSSN DEPARTMENT • RESULT πFNAM, MINIT, LNAME, DNAME (TEMP)