0% found this document useful (0 votes)
4 views

Chapter 6

Uploaded by

karleinstein161
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Chapter 6

Uploaded by

karleinstein161
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Chapter 6

The Physical Model of Data: the relational model

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.

 Different types of data

Type Definition particularities Examples

alphanumeric It is composed of It is characterized by Designation of a


or text alphabetic or numeric their length: you must product.
characters that do not specify the maximum - Postal code.
require a mathematical number of characters. - Bill number.
treatment.
Digital It is the subject of a These values are Unit price of a
calculation and is reserved for data which product.
sometimes accompanied by can be processed - Total amount on
a measurement unit (€, mathematically. an invoice.
time, km, kg ...).
Logic / It has two possible values Man/Woman.
Boolean [yes/no], [true/false].

Date/time It helps treat time When dates are subject to calculations, it is


digital data.
For example, the time between two dates.

2. Domains of values and attributes


An attribute (column of the table) represents a characteristic of an element of a
database. An attribute is identified by a name and a domain value, i.e. the set of values that it
can take.

1
Example: the element "student" is characterized by the following attributes: student_Id,
student_NAME, student_FIRSTNAME and class_Code.

Attributes

student_Id student_NAME student_FIRSTNAME class_Code


1 NJI Nixon TST1
2 BACHE Clinton FIG7 Tuple
3 SIRRI Rachel MEB7
4 TABOT Stanley AM6

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

Determining element Determined element

 Compound determining element: several attributes are sometimes necessary to


determine an attribute. Example: Order_Num, Product_Ref  order_QTY.
For the quantity ordered, you must know the order number and the product number.
 Compound determined Element: the same attribute can determine several other
attributes.
Example: Subject_Code → Subject_Name , Subject_Coeff
In this example, the attribute code determines both the name and the coefficient of the
material.
4. Relation and relational schema
A relation is a set of attributes necessary to describe an object. For the object (=
person) "student", the attributes are needed to describe the number, name, first name and class.
There are two representations of relations:
 A graphical representation:
Student
student_Id
student_NAME
student_FIRSTNAME
class_Code

 A textual representation

Student (student_Id, student_NAME, student_FIRSTNAME, #class_Code)

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:

query name Relation Joint criteria Selection Sort criteria Projected


criteria attributes

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

3. The restriction or selection


a. Definition
The restriction consists to select one or more attributes based on one or more criteria. We
introduce before the criteria:
- Comparison operators such as =,>, <, < >,> =, <=
- Logical operators AND, OR, NOT
b. Example
From the relational model the tree festival, list the members (full names: names and surnames)
aged of 15.
Query name Relation(s) join selection Sort projected
Criterion Criterion Criterion attributes
List of MEMBER age = 15 years membername
Members membersurname
age 15

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

c. The structure of a table


A table of a database consists of rows and columns. A table line is the record and a column is
called field.
The primary key is used to uniquely identify a record in a table. The values of a primary key
must be unique, stable and non-null.
A foreign key indicates a link to another table. The foreign key is necessarily the primary key
of another table.
In the NBA database the franchise_name field is a foreign key to the table Coach and primary
key the Franchise table. The franchise_name field is the primary key because the name of the
teams is unique, which is not the case for the other two fields of the Franchise table. Indeed, the
franchise_town field cannot be primary key because it is possible that two franchises are
domiciled in the same city.

5
Primary key Field of the names of the towns of franchises

Franchise_name franchise_town payroll

Record

The table contains 30 records

d. The management of constraints


i. The domain constraint
Each field takes values in a defined area (definition in extension) or type (definition in
intention). In the Access RDBMS, we find the following types:

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.

Counter Incremented number (up 1) automatically each new record.


Yes/No Fields that contain only one of two possible values, including
Yes/No or True/False.

ii. Reference constraint: primary key and foreign key link

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.

You might also like