modelisation (1)
modelisation (1)
RELATIONNELLE
prof
Tartempion
nom
Loria
laboratoire
1
Modèle de
n
données
cours base de données C++ réseau
titre septembre décembre avril
mois
interfaces de navigation
procédurales : on exprime
comment accéder à la donnée plutôt
que la donnée qu’on cherche →
programmes dépendants de la
structure des données
Peter Chen
• informations organisées sous forme de tables, les
relations entre les tables sont elles-mêmes des tables
• la manipulation s’appuie sur des opérations d’algèbre
relationnelle (produit cartésien pour les associations)
1. entity/relationship model
2. transformation to relational model
3. normalization
• example:
Library(Title, Author, ISBN, Name, Address, Date)
entity-relationship diagram
systematic process
Name: String
FirstName: String
Address: String
attributes SSNb: int key
BirthDate: int
definitions
• occurrence: instantiation of an entity
Person
Name: String
isManagedBy
FirstName: String
Address: String
Age: int
Person
Car
Name: String
Reg: String 1 .. 1 BelongsTo 0 .. n
FirstName: String
Type: String PurchaseDate: int Address: String
Brand: String
Age: int
Color: int
Gender:int
Caution! In UML the cardinalities are indicated on the opposite side of the relation:
Person
Car
Owner
Name: String
Reg: String
FirstName: String
Type: String OwnedCars Address: String
Brand: String
Age: int
Color: int 0 .. n Gender:int
examples (2/4)
3 entities connected by 2 associations
Borrower
Book
Name: String
? Borrows ?
FirstName : String
BorrowingDate: int Title : String
ISBN :String
Address :String
?
isWrittenBy
?
Author
Name: String
FirstName: String
examples (2/4)
3 entities connected by 2 associations
Borrower
Book
Name: String
0 .. n Borrows 0 .. 1
FirstName : String
BorrowingDate: int Title : String
ISBN :String
Address :String
1 .. n
isWrittenBy
1 .. n
Author
Name: String
FirstName: String
examples (3/4)
Car 1 .. n isUsedBy
0 .. n Person
Number: int
Date : int
Description: String
1 .. 1
Bing
0 .. n
Car 1 .. n isUsedBy
0 .. n Person
Schedule
0 .. n id: int
StartTime: Time
MovieTheater EndTime: Time
id: int
Name: String 0 .. n Offers
id: int
0 .. n Title: String
Year: Date
tips
transform ternary association into binary association
1. replace the association by a new entity
2. create associations between entities,
cardinality of new entity always being 1
Schedule
0 .. n
id: int
startAt StartTime: Time
EndTime: Time
MovieTheater 1 ..1
0 .. n id: int
Title: String
Year: Date
description of “the case”
Additional Test
code: int
description: String
Examination
code: int
description: String
Problem:
an association binds (preferably) entities, not
associations
modeling an appointment
Doctor
Patient
id: int
0..n SSnb: int
Name: String 0..n
Name: String
Specialties: String
conduct undergo Age: int
1..1 1..1
Consult
id: int
date: Date
0..n 1..n
isPrescribed isPerformed
Comment choisir ?
Cela ne dépend pas de nous (concepteurs) mais des besoins de l'application (i.e. des utilisateurs).
• Dans le 1er cas, la "réification" de la notion de maladie va orienter l'application vers des fonctionnalités essentiellement
médicales : on pourra comparer plusieurs patients atteints de la même maladie, les protocoles de soins que l'on a utilisés,
leur efficacité, etc. Bref faire quelque chose qui ressemble à de l'aide à la recherche médicale. On se dirige alors vers une
application lourde (une base de données de toutes les maladies connues de la planète, des protocoles de soins connus ou
à expérimenter), une application qui participe à l'amélioration de la santé de tous.
• Dans le 2ème cas, l'application va se contenter d'offrir des fonctionnalités purement administratives : permettre de
consultation en consultation de retrouver aisément sur un écran ce qui avait été précédemment noté. On se dirige cette
fois vers une application légère, utile au quotidien, mais inexploitable sur le plan de la recherche médicale. En effet il est
très difficile d'extraire à partir de commentaires de circonstance et rédigés en langue naturelle des informations d'ordre
général (et en tout cas, pas de manière automatisée) : il existe actuellement dans les hôpitaux du monde entier des
mines d'informations dans des fichiers manuels que l'on ne sait guère exploiter.
1..1 1..1
Consult
id: int
date: Date
diagnosis: String
0..n 1..n
isPrescribed isPerformed
1..1 1..1
Consult
id: int
date: Date
diagnosis: String
0..n 1..n
isPrescribed isPerformed
1..1 1..1
0..n Consult
isPrescribed
Drug id: int
name: String date: Date
0..n
diagnosis: String
0..n 1..n
isPrescribed isPerformed
1..1 1..1
0..n Consult
isPrescribed
Drug id: int
quantity
name: String date: Date
0..n
diagnosis: String
0..n 1..n
isPrescribed isPerformed
entity-relationship diagram
systematic process
1 .. 1
Bing
0 .. n
Car 1 .. n isUsedBy
0 .. n Person
• → alternative transformations
case E1 0..1 - 0..1 E2
add to one entity (E1 or E2) the identifier of the other
and the attributes of the association
If a teacher can supervise at most one thesis at a time:
Professor PhDStudent
Professor PhDStudent
possible issue:
Name StudId how to
FirstName Name represent a
ResearchTopic FirstName teacher who is
Laboratory Funding not advising a
StudId PhD student?
StartDate
case E1 0..1 - 1..1 E2
add to E2 the identifier of E1 and the attributes of the
association
Professor PhDStudent
Professor PhDStudent
StudentId
Name Name
FirstName FirstName
ResearchTopic Funding
Laboratory advisorName
advisorFirstName
advisorReasechTopic
StartDate
case E1 1..1 - 1..1 E2
add to one entity (E1 or E2) the identifier of the other
entity and the attributes of the association
Opportunity to do reduce to one single relation
If every teacher teaches a lesson and one only:
Course
Professor
1 .. 1 teach 1 .. 1
Title
Name room Duration
FirstName
Level
CallForPproposals
Professor
0 .. 1 propose 0 .. n Reference
Name
ResponseDate Field
FirstName
Duration
ResearchTopic
Funding
Professor CallForProposals
possible issue:
Name Reference how to
First name Field represent a
ResearchTopic Duration teacher who do
Reference Funding not make a
ResponseDate proposal?
case E1 x..n - y..n E2
association gives a new relation
Article
Professor
0 .. n Publish 1 .. n Title
Name
ContractId Conference
First name
NbOfPages
ResearchTopic
Date
campus does not belong to the key and depends only on majName → not in 2NF
solution:
techName does not belong to the key and depends on teachId which does not belong to
the key neither→ not in 3NF
solution:
address
addr1 (Zipcode, City)
(City,Street,Number,Zipcode)
• City, Street, Number → Zipcode addr2 (Zipcode,Street,Number)
• Zipcode → City
there are other NF
1NF
2NC
3NF
BCNF
4NF
5NF
DKNF
6NF
normalization: conclusion
gradually evolve from few large tables to many
small tables
• consistency
• but require more joins