Lecture 4
Lecture 4
The Relational
Relational Model
Model
1
Queries
• IBM’s San José Research Laboratory in California, was the prototype relational
DBMS System R, which was developed during the late 1970s (Astrahan et al.,
1976).
• This project was designed to prove the practicality of the relational model
by providing an implementation of its data structures and operations
• It also proved to be an excellent source of information about
implementation concerns such as transaction management, concurrency
control, recovery techniques, query optimization, data security and
integrity, human factors, and user interfaces, and led to the publication of
many research papers and to the development of other prototypes.
• Development of a structured query language called SQL
• Production of various commercial relational DBMS products DB2 and
SQL/DS from IBM and Oracle from Oracle Corporation
INGRES
A relation with only one attribute would have degree one and be
called a unary relation or one-tuple.
Super key
Candidate Key
Primary Key
Foreign Key
Super Key
A Super Key is a set of one or more attributes (columns) that
can uniquely identify a record in a table. A super key may
contain additional attributes that are not necessary for unique
identification.
Example: Consider a table named Employees
Candidate Key
A Candidate Key is a minimal super key, meaning it is a super
key with no unnecessary attributes. In other words, a candidate
key is the minimal set of attributes that can uniquely identify a
record.
Example: In the Employees table:
{EmployeeID} is a Candidate Key because it uniquely identifies each
employee, and removing any attribute would prevent it from being
unique.
{Email} could also be a Candidate Key if we assume that each
employee has a unique email.
Natural Key
A Natural Key is a key that has a real-world meaning and is
derived from existing data. For example, a Social Security
Number or Email can be used as a natural key to uniquely
identify individuals.
Terminology
Attribute names
tuples
Integrity Constraints
Null:
Represents a value for an attribute that is currently unknown or is not
applicable for this tuple.
A null can be taken to mean the logical value “unknown.” It can mean that
a value is not applicable to a particular tuple, or it could merely mean that
no value has yet been supplied. Nulls are a way to deal with
incomplete or exceptional data.
However, a null is not the same as a zero numeric value or a text string
filled with spaces; zeros and spaces are values, but a null represents the
absence of a value
For example, in the Viewing Relation the comment attribute may be
undefined until the potential renter has visited the property and
returned his or her comment to the agency.
Integrity Constraints
Entity Integrity:
The first integrity rule applies to the primary keys of base relations
By definition, a primary key is a minimal identifier that is used to identify
tuples uniquely.
This means that no subset of the primary key is sufficient to provide
unique identification of tuples. If we allow a null for any part of a primary key,
we are implying that not all the attributes are needed to distinguish between
tuples, which contradicts the definition of the primary key.
For example, if an upper limit of 20 has been placed upon the number of staff
that may work at a branch office, then the user must be able to specify this
general constraint and expect the DBMS to enforce it.
In this case, it should not be possible to add a new member of staff at a given
branch to the Staff relation if the number of staff currently assigned to that
branch is 20.
Views
In the three-level ANSI-SPARC architecture, we described an
external view as the structure of the database as it appears to a
particular user.
Relationships relations
price
makes Company
Product
Stock price
buys employs
Person
price
Product
Product:
makes Company
Product
Stock price
Relation MAKES (watch out for attribute name conflicts)
Relation TEAM:
Product
Platforms
required memory ageGroup
topic
Software Educational
Product Product
Educ-software Educational-method
Product
Option #1: the ODL Approach
Some values in the table will be NULL, meaning that the attribute
not make sense for the specific product.