Chapter 6
Chapter 6
The relational model represents the database as a set of tables, without prejudging the way
information is stored in the computer.
A. Data and relations
1. Data
Definition
A datum is the basic element of information useful to an organisation. It constitutes the raw
material to management.
A datum may be:
- Elementary, that is, it cannot be obtained from other data;
- Calculated, that is, it is the combination of other data.
1
Example: the element "student" is characterized by the following attributes: student_Id,
student_NAME, student_FIRSTNAME and class_Code.
Attributes
3. Functional dependence
Consider two attributes A and B. A is in functional dependence of B if the knowledge of a value
of A determines the knowledge of one and only one value of B.
The functional dependence is schematically denoted:
A B Translated by A determines B
A textual representation
2
The relational schema is the representation of all relations of the area studied. If the study area
is the size (number of students) of a high school, the relational schema can be:
Student (student_Id, student_NAME, student_FIRSTNAME, class_Code#)
Class (class_code, class-name, class_thread, size)
Or
Student Class
student_Id class_code
student_NAME class-name
student_FIRSTNAME class_thread
class_Code size
B. Relational operators
1. Definition
The relational operators designate an action on a relation. They allow to query the database by
creating queries.
Three relational operators will be studied:
• Projection,
• Restriction or selection,
• The joint.
2. The projection
a. Definition
The projection is to retain only certain attributes (fields) of a relation (table).
b. Method
To facilitate the reasoning, it builds a table of the following form:
Give an
explicit name List the We use one or more columns (fields) Expected
relations used according to the query to execute result
Note: This table is applicable for other relational operators (restriction and join).
c. Example
The association (relationship) the festive tree hosted several workshops for young people
between 7 and 18 years. The head of the association has set up a database based on the following
relational model:
MEMBER (membernum, membername, membersurname, memberage, memberaddress)
WORKSHOP (workshopnum, workshopdesignation, #anonnum)
ANNOUNCER (anonnum, anonname, anonsurname, anonaddress)
PARTICIPANT (membernum, workshopnum, startdate, enddate)
3
The association decides to list in alphabetical order (ascending order) the names of members
and their ages. The query looks like this:
Query name Relation(s) join selection Sort projected
Criterion Criterion Criterion attributes
List of MEMBER Name in ascending order membername
Members membersurname
memberage
4. Joining
a. Definition
The join consists to connect two or more relationships through a common attribute.
b. Example
From the relational model the tree in festival, the head of the association lists the name and
surname of the announcers (moderators) involved in the painting workshop.
Query name Relation(s) join selection Sort projected
Criterion Criterion Criterion attributes
Painting WORKSHOP ANNOUNCERS.anonnum = anonname
announcers ANNOUNCERS WORKSHOP.anonnum anonsurname
workshopdesignation = painting
C. The database
The diagram of the database (relational diagram)
a. Definition of a database
A database is a collection of information structured in tables of which the
implementation, updating and exploitation are carried out using a relational database
management system (RDBMS). It is defined by its schema (structure) and its contents
(values).
4
b. From the relational model to the physical model
The physical implementation (on the machine) of the database is the next step (after the data
model) of the creation of a database.
The relational model (logical level) is a representation of the system as it will be implemented
in computers. The relational model is independent of the chosen RDBMS. That is why we
distinguish the vocabulary of relational model of the vocabulary from the physical model.
The vocabulary of the passage from the relational model to the physical model is shown in the
table below:
Relational model Physical model
Attribute Field
Primary key Primary key
Tuple Record
Relation Table
5
Primary key Field of the names of the towns of franchises
Record
6
Type of fields Use
Text Text or combinations of text and numbers, such as addresses. Also
includes numbers that do not require calculations, such as phone
numbers, part numbers, or postal codes.
Memo Long series of alphanumeric characters such as notes or
descriptions.
Numerical Digital data to which mathematical calculations must be applied,
with the exception of monetary calculations (for which you must use
the Currency type).
Date/hour Dates or times. There are several display formats.
Monetary Monetary values expressed in euro.
The reference constraint is that the value taken by a foreign key must match the value taken by
the primary key in another relationship.
In the example below, a franchise name cannot be entered in the Coach table if it does not exist
as a primary key in the table Franchise.