Lecture 07 relational database management system


Published on

Published in: Education
1 Like
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Lecture 07 relational database management system

  1. 1. Lecture 7 Relational Database Management System
  2. 2. The Relational Model <ul><li>Due to Codd. </li></ul><ul><li>Everything is represented as a relation. </li></ul><ul><li>A database therefore is a collection of tables, each of which has a unique name, and each of which is described by a schema. </li></ul><ul><li>In addition, Codd defined a data manipulation language . </li></ul>
  3. 3. Example of Schemas in the Relational Model <ul><li>Example of a representation of entity sets: </li></ul><ul><ul><li>Student( sid ,name,addr) </li></ul></ul><ul><ul><li>Course( cid ,title,eid) </li></ul></ul><ul><ul><li>Empl( eid , ename, deptid) </li></ul></ul><ul><ul><li>Dept( deptid , dname, loc) </li></ul></ul><ul><li>Primary keys are underlined. </li></ul><ul><li>Recall that a primary key is one that uniquely identifies an entity. </li></ul><ul><li>An entity is a row in a table. </li></ul>
  4. 4. Relational Databases: Basic Concepts I <ul><li>Attribute: </li></ul><ul><ul><li>A column in a table </li></ul></ul><ul><li>Domain </li></ul><ul><ul><li>The set of values from which the values of an attribute are drawn. </li></ul></ul><ul><li>Null value </li></ul><ul><ul><li>A special value, meaning “not known” or “not applicable”. </li></ul></ul><ul><li>Relation schema </li></ul><ul><ul><li>A set of attribute names </li></ul></ul>
  5. 5. Relational Databases: Basic Concepts II <ul><li>Tuple </li></ul><ul><ul><li>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 </li></ul></ul><ul><li>Relation instance </li></ul><ul><ul><li>A set of tuples over the scheme of the relation </li></ul></ul>
  6. 6. Relational Databases: Basic Concepts III <ul><li>Relational Database </li></ul><ul><ul><li>A set of relations, each with a unique name </li></ul></ul><ul><li>Normalized Relation </li></ul><ul><ul><li>A relation in which every value is atomic (non-decomposable). Hence, every attribute in every tuple has a single value. </li></ul></ul>
  7. 7. Keys <ul><li>Candidate Key </li></ul><ul><ul><li>A minimal set of attributes that uniquely identifies a tuple </li></ul></ul><ul><li>Primary Key </li></ul><ul><ul><li>The candidate key chosen as the identifying key of the relation </li></ul></ul><ul><li>Alternate Key </li></ul><ul><ul><li>Candidate keys which are not primary keys </li></ul></ul>
  8. 8. <ul><li>Foreign Key </li></ul><ul><ul><li>An attribute (or set of attributes) in table R1 which also occurs as the primary key of relation R2. </li></ul></ul><ul><ul><li>R2 is called the referenced relation. </li></ul></ul><ul><ul><li>Foreign keys are also called connection keys or reference attributes . </li></ul></ul>
  9. 9. Integrity Rules: Entity Constraint <ul><li>Entity constraint </li></ul><ul><ul><li>All attributes in a primary key must be non-null. </li></ul></ul><ul><ul><li>Motivation: If the primary key uniquely identifies an entity in an entity set, then we must ensure that we have all the relevant information </li></ul></ul>
  10. 10. Integrity Rules: Referential Integrity <ul><li>Referential integrity </li></ul><ul><ul><li>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. </li></ul></ul><ul><ul><li>Or, a foreign key must refer to a tuple that exists. </li></ul></ul><ul><ul><li>Motivation: If referential integrity were violated, we could have relationships between entities that we do not have any information about. </li></ul></ul>
  11. 11. Codd Rules <ul><li>Rules for a Database to qualify as Relational Database </li></ul><ul><ul><li>Information Rule </li></ul></ul><ul><ul><li>Guaranteed Access Rule </li></ul></ul><ul><ul><li>Comprehensive Data Sub-language Rule </li></ul></ul><ul><ul><li>View Update Rule </li></ul></ul><ul><ul><li>High Level Insert, Update and Delete </li></ul></ul><ul><ul><li>Physical Data Independence </li></ul></ul><ul><ul><li>Logical Data Independence </li></ul></ul><ul><ul><li>Integrity Independence </li></ul></ul><ul><ul><li>Non Subversion Rule </li></ul></ul><ul><ul><li>Systematic Treatment of Null Values </li></ul></ul><ul><ul><li>Database Description Rule </li></ul></ul><ul><ul><li>Distribution Independence </li></ul></ul>
  12. 12. Data Manipulation Languages <ul><li>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. </li></ul><ul><li>One of the attractions of the relational data model is that it comes with a well-defined data manipulation language. </li></ul>
  13. 13. Types of DML <ul><li>Two types of data manipulation languages </li></ul><ul><ul><li>Navigational (procedural) </li></ul></ul><ul><ul><ul><li>The query specifies (to some extent) the strategy used to find the desired result e.g. relational algebra. </li></ul></ul></ul><ul><ul><li>Non-navigational(non-procedural) </li></ul></ul><ul><ul><ul><li>The query only specifies what data is wanted, not how to find it e.g. relational calculus. </li></ul></ul></ul>