Lecture7 8 - The Relational Model
Lecture7 8 - The Relational Model
Database Systems
3
Introduction to relational model
6
The Relational Model Concepts
▪ This perception applies only to the logical structure of the database: that is,
the external and conceptual levels of the ANSI-SPARC architecture.
▪ In the relational model, relations are used to hold information about the
objects to be represented in the database.
▪ The relational model uses a collection of tables to represent both data and
the relationships among those data.
▪ Each table has multiple columns, and each column has a unique name.
8
Properties of Relations
• the relation has a name that is distinct from all other relation names in the relational schema;
• each cell of the relation contains exactly one atomic (single) value;
• each attribute has a distinct name;
• the values of an attribute are all from the same domain;
• each tuple is distinct; there are no duplicate tuples;
• the order of attributes has no significance;
• the order of tuples has no significance, theoretically. (However, in practice, the order may
affect the efficiency of accessing tuples.)
9
Mathematical Relations
▪ To understand the true meaning of the term relation, we have to review some concepts from
mathematics.
▪ Suppose that we have two sets, D1 and D2, where D1 = {2, 4} and D2 = {1, 3, 5}.
▪ The Cartesian product of these two sets, written D1 x D2, is the set of all ordered pairs such that
the first element is a member of D1 and the second element is a member of D2.
▪ An alternative way of expressing this is to find all combinations of elements with the first from D1
and the second from D2. In our case, we have:
▪ D1 x D2 = {(2, 1), (2, 3), (2, 5), (4, 1), (4, 3), (4, 5)}
▪ Any subset of this Cartesian product is a relation. For example, we could produce a relation R
such that: R = {(2, 1), (4, 1)}
10
Database Relations
11
Database Relations
12
Relational Keys
▪ Primary key: The candidate key that is selected to identify tuples uniquely within the
relation.
▪ Alternate Key: The candidate key other than the primary key is called an alternate key.
▪ Superkey: The set of attributes that can uniquely identify a tuple is known as Super Key. A
super key is a group of single or multiple keys that identifies rows in a table.
▪ Foreign key: An attribute, or set of attributes, within one relation that matches the candidate
key of some other (master) relation.
▪ Composite Key: Sometimes, a table might not have a single column/attribute that uniquely
identifies all the records of a table. To uniquely identify rows of a table, a combination of two
or more columns/attributes can be used. E.g., FULLNAME + DOB can be combined.
13
Relational Keys
14
Representing Relational Database Schemas
15
Integrity
Constraints
A null represents a value for an attribute that is unknown at the present time or is not applicable for this tuple.
16
Database Views
▪ Views provide security and allow the designer to customize a user’s model.
17
Purpose of
Views
18
Database Views (By Example)
19
Thankyou
Any Queries?
20