TI404 - Introduction To Databases: Maha Naceur/Laurent Cetinsoy
TI404 - Introduction To Databases: Maha Naceur/Laurent Cetinsoy
TI404 - Introduction To Databases: Maha Naceur/Laurent Cetinsoy
databases
Part 2
2021 - 2022
02
Database design
and modelling
How do we structure
data in a database ?
Are there rules to follow
?
What should be avoided
?
Model E/A
Relational model
Normalizing
Database design process
You can design databases without Physical data model : implementation of the DB in a DBMS
from the LDM (and optimization)
thinking about the Database
management system specifities !
Do not think about the software,
think about the concepts
Life cycle
Specification Of
the DB
1. Conceptual data
Merise -> Model model (CDM)
Conception
conceptuel de
donnée Conceptual
(abstract) diagram
Physical
Transformation
Design
into a logic
2. Logical Data Model
model
(LDM)
Spécifique à un SGBD
Analyze well, model well!
Model well
requires the use of modeling
existing situation and
formalisms such as E-A or UML
the needs relies on the
engineer's expertise
The logical model is deduced in a
systematic way from the conceptual
model and the software
implementation is realized by direct
translation of the logical model.
Needs of description
Conceptual modeling Describe the application data (trains, trips and reservations) without referring to a specific IT
solution
Logical modeling (Data Develop an equivalent description for the data storage in the chosen DBMS (the collections:
Description Language ticket, train and stop)
(LDD))
Language for data Create the initial database with the data representing the SNCF network (insert the different
insertion information: ticket, train and stop by setting up the relations between them)
Data manipulation Create as you go the data on the reservations. To be able to modify (and possibly delete) any
language (DML) data already entered (if late, update the departure time of train X)
Query language (query Respond to any request for information on the data contained in the database (Display all trains
language) leaving at 10am from Nantes station)
Language for expressing It is necessary to be able to express all the rules that constrain the values that can be recorded
integrity constraints in such a way as to avoid any error that may be detected (ticket X and stop Y depend on a train
number Z)
Description requirements
Reliability The information (e.g. reservations) must not be lost due to any kind of malfunction:
guarantee programming error, system failure, computer failure, power failure, ...
Competition An action done for one user (e.g. booking a reservation) must not be lost because of
control another action done simultaneously for another user (booking the same place)
guarantee
Confidentiality All information must be protected from access by unauthorized users in read or write mode.
guarantee Example: Prohibit customers from changing train numbers or schedules or their
reservations.
Optimization The response time of the system must be in accordance with the needs: in interactive: not
mechanisms more than 3 seconds, in programming: fast enough to assume the expected workload
(number of transactions per day)
Entity/Association
You want to
Model
describe the
problem in term of
entity and
association
between entity
Model E/A
➢An entity is similar to the notion of object / concept, it describes an "entity" of the real
world.
➢Example: a book, a student, an account, an invoice, ...
➢An association is a link between several entities
➢Example: an invoice contains several products.
E/A: informal representation
“let a database describing films, with their directors and actors, as well as the theaters where
these films are shown. This database is accessible on the Web and Internet users can rate
the films they have seen.
Same MES
Same
year
E/A : formal representation
Associations
Entities will
more Attributes
information : Attributes
attributes
Key : Let E be an entity type, A the set of its attributes, a key of E is a minimal subset of A, allowing to uniquely
identify an entity among any extension of E
Examples : id_Film to identify a film, the pair (email, password) to identify an internet user, etc
Clés
Attributs
Entités
Choice of the identifier
❑ Avoid identifiers composed of several attributes (such as, for example, an identifier formed by the attributes
name and first name):
✓ they degrade the performance of the DBMS,
✓ but above all, the uniqueness assumed by such an approach usually ends up, sooner or later, being
denied
❑ Avoid identifiers that may change over time (such as a vehicle license plate)
➢ An association (sometimes called a relation) represents the semantic links that can exist between several entities
➢ An association class (or type) contains all similar associations (that link entities belonging to the same entity classes)
Association
➢ An association class can link more than two entity classes. Here are the names of the association classes:
– a recursive (or reflexive) association class links the same entity class
– a binary association class links two entity classes
– a ternary association class links three entity classes
– an n-ary association class links n entity classes
Cardinality
Cardinality : Let be an association (E1, E2) between two types of entities. The cardinality of the association for
Ei (E1 or E2) is a pair [Min, Max] such that :
➢ Max : maximum cardinality which designates the maximum number of times an instance ei of Ei can
intervene in the association (1 or n)
➢ Min : minimal cardinality that designates the minimal number of times an instance ei of Ei in the
relation (0 or 1)
Exemple : An artist(MES) makes 0 or more films and a film is made by one and only one artist(MES).
min
max
Relationship between n types of entities E1, E2,..,En is a set of n-tuples (e1, e2,..,en) where each ei belongs to Ei
Exemple :
at 5 pm.
A few tips
o Name standardization: The name given to an entity, an association or an attribute must be
unique
➢ Risk of inconsistency if attributes have the same name but also of redundancy, waste of
memory space Try not to use
abbreviation : clear and
precises are better
A few tips
o Standardization of attributes
o Each multiple attribute (structure) must be transformed into an entity and an additional
association is added
o Same for an enumeration (example for Film, the attribute "Genre" ={action, comedy,
fiction,...})
o Avoid information redundancy of attributes by calculation or transition: an attribute
derived from other attributes
Merger of entities
Association merger
A few tips
o Make deletions when possible
o We must ask ourselves the question of the interest of an association when the
maximum cardinalities are all equal to 1
possible
deletion Non possible
deletion
A few tips
o If there are two paths to get from one entity to another, then these two paths must have two
distinct meanings.
o Otherwise, the shortest path must be deleted since it is deductible from the other paths
From an n-ary association to an entity type
Let A be an association between the entity types {E1, E2,.., En}. The transformation of A into an
entity type is done in three steps:
•In general, an entity is •We generally limit •Let's say we have two
created if it has at least 2 ourselves to the subscribers named "John", it
occurrences. properties necessary for is necessary to distinguish
the development between them or they will be Generally indicated
•Each element of an entity confused. Generally verbs
is called an occurrence of •Each property must have explicitly in the text
•We then add a property that
the entity only one possible value will uniquely identify each
for each occurrence, occurrence: Primary Key
otherwise it is an entity. •This key is underlined to
•It must also be highlight its role as an
elementary and non- identifier
decomposable (The
address property (street,
postal code, city) is
composed of 3
elementary entities)
Application : Newsletter
"A subscriber is subscribed to one or more column. Each column sends a NewsLetter
every week to the subscribers who registering to the corresponding column. A
subscriber can choose one out several reasons for subscribing."
These sentences, if they are accurate and validated by the client, are sufficient to
model our first model. They contain all the necessary information.
Application : Newsletter
"A training company wants to computerize the management of registrations for the
sessions it organizes, as well as the invoicing. There are a number of training
seminars, each devoted to a different theme and billed at a specific rate. A seminar
can be held more than once, which corresponds to as many sessions. The sessions
of a seminar are held on different dates. Some companies register their employees
for certain sessions. There is a maximum number of participants for each seminar
session (regardless of the date of the session). Each month, the company invoices
each company for the amount of money its employees have spent in the past
month's sessions."
Application : Société de formation
Application: Newsletter (Final standardized version)
Application: Hospital management
Application: Training company
Approach to building an E/A model
1. Pragmatic approach: :
Based on the designer's intuition. Entities and associations are built from the entity definition
✓ Advantage : speed
✓ Disadvantage : risk of only modeling the existing
2. Formal approach :
Establish the data dictionary
Eliminate redundancies
Locate the identifiers and identify the material entities
Attach to entities the properties in DFM (functional dependencies) with their identifiers
Add the associations and assign them properties in DF with the identifiers of the
participating entities
Simplify the model using FICs (Functional Integrity Constraints)
Check the conceptual data model
E/A in a nutshell!
Non-determinism:
•No hard and fast rule for determining what is an
entity, attribute or relationship.