Lecture 7 Relational Database Management System
The Relational Model Due to Codd. Everything is represented as a relation.  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 .
Example 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 primary key is one that uniquely identifies an entity. An entity is a row in a table.
Relational Databases: Basic Concepts I Attribute: A column 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
Relational 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
Relational Databases: Basic Concepts III Relational Database 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.
Keys Candidate Key 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
Foreign Key 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 .
Integrity Rules: Entity Constraint Entity constraint All attributes in a primary key must be non-null. Motivation: If the primary key uniquely identifies an entity in an entity set, then we must ensure that we have all the relevant information
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.
Codd Rules Rules for a Database to qualify as Relational Database Information Rule Guaranteed Access Rule Comprehensive Data Sub-language Rule View Update Rule High Level Insert, Update and Delete Physical Data Independence Logical Data Independence Integrity Independence Non Subversion Rule Systematic Treatment of Null Values Database Description Rule Distribution Independence
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.
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. relational algebra. Non-navigational(non-procedural) The query only specifies what data is wanted, not how to find it e.g. relational calculus.

Lecture 07 relational database management system

  • 1.
    Lecture 7 RelationalDatabase Management System
  • 2.
    The Relational ModelDue to Codd. Everything is represented as a relation. 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 .
  • 3.
    Example of Schemasin 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 primary key is one that uniquely identifies an entity. An entity is a row in a table.
  • 4.
    Relational Databases: BasicConcepts I Attribute: A column 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
  • 5.
    Relational Databases: BasicConcepts 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
  • 6.
    Relational Databases: BasicConcepts III Relational Database 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.
  • 7.
    Keys Candidate KeyA 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
  • 8.
    Foreign Key Anattribute (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 .
  • 9.
    Integrity Rules: EntityConstraint Entity constraint All attributes in a primary key must be non-null. Motivation: If the primary key uniquely identifies an entity in an entity set, then we must ensure that we have all the relevant information
  • 10.
    Integrity Rules: ReferentialIntegrity 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.
  • 11.
    Codd Rules Rulesfor a Database to qualify as Relational Database Information Rule Guaranteed Access Rule Comprehensive Data Sub-language Rule View Update Rule High Level Insert, Update and Delete Physical Data Independence Logical Data Independence Integrity Independence Non Subversion Rule Systematic Treatment of Null Values Database Description Rule Distribution Independence
  • 12.
    Data Manipulation LanguagesIn 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.
  • 13.
    Types of DMLTwo types of data manipulation languages Navigational (procedural) The query specifies (to some extent) the strategy used to find the desired result e.g. relational algebra. Non-navigational(non-procedural) The query only specifies what data is wanted, not how to find it e.g. relational calculus.