Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 13

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
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
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.

You might also like