www.getmyuni.com

Lecture 7

Relational Management System www.getmyuni.com The

• Due to Codd. • Everything is represented as a . • A database therefore is a collection of tables, each of which has a unique name, and each of which is described by a schema. • In addition, Codd defined a data manipulation language. www.getmyuni.comExample of Schemas in the Relational Model • Example of a representation of entity sets: Student(sid,name,addr) Course(cid,title,eid) Empl(eid, ename, deptid) Dept(deptid, dname, loc) • Primary keys are underlined. • Recall that a is one that uniquely identifies an entity. • An entity is a in a . www.getmyuni.com Relational : Basic Concepts I • Attribute: – A in a table

• Domain – The set of values from which the values of an attribute are drawn.

• Null value – A special value, meaning “not known” or “not applicable”.

• Relation schema – A set of attribute names www.getmyuni.comRelational Databases: Basic Concepts II • Tuple – A set of values, one for each attribute in the relation scheme over which the tuple is defined, i.e. a mapping from attributes to the appropriate domains

• Relation instance – A set of tuples over the scheme of the relation www.getmyuni.com Relational Databases: Basic Concepts III • – A set of relations, each with a unique name

• Normalized Relation – A relation in which every value is atomic (non-decomposable). Hence, every attribute in every tuple has a single value. www.getmyuni.com Keys

– A minimal set of attributes that uniquely identifies a tuple

• Primary Key – The candidate key chosen as the identifying key of the relation

• Alternate Key – Candidate keys which are not primary keys www.getmyuni.com

– An attribute (or set of attributes) in table R1 which also occurs as the primary key of relation R2. – R2 is called the referenced relation. – Foreign keys are also called connection keys or reference attributes. www.getmyuni.com Integrity Rules: Entity Constraint • Entity constraint – All attributes in a primary key must be non- . – Motivation: If the primary key uniquely identifies an entity in an entity set, then we must ensure that we have all the relevant information www.getmyuni.com Integrity Rules: Referential Integrity • Referential integrity – A database cannot contain a tuple with a value for a foreign key that does not match a primary key value in the referenced relation. – Or, a foreign key must refer to a tuple that exists. – Motivation: If referential integrity were violated, we could have relationships between entities that we do not have any information about. www.getmyuni.com Codd Rules

• Rules for a Database to qualify as Relational Database 1. Information Rule 2. Guaranteed Access Rule 3. Comprehensive Data Sub-language Rule 4. View Update Rule 5. High Level Insert, Update and Delete 6. Physical Data Independence 7. Logical Data Independence 8. Integrity Independence 9. Non Subversion Rule 10.Systematic Treatment of Null Values 11.Database Description Rule 12.Distribution Independence www.getmyuni.com Data Manipulation Languages

• In order for a database to be useful, it should be possible to store and retrieve information from it. This is the role of the data manipulation language.

• One of the attractions of the relational data model is that it comes with a well-defined data manipulation language. www.getmyuni.com Types of DML

• Two types of data manipulation languages – Navigational (procedural) • The query specifies (to some extent) the strategy used to find the desired result e.g. . – Non-navigational(non-procedural) • The query only specifies what data is wanted, not how to find it e.g. .