SlideShare a Scribd company logo
1 of 50
Download to read offline
Gegevensbanken
entiteit-relatie model



Prof. Erik Duval
2010-2011

                   1
http://www.slideshare.net/erik.duval




2
3
•   ontwerp van een gegevensbank
•   conceptuele gegevensmodellen
•   voorbeeld
•   E-R model
•   E-R diagrammen
•   ontwerpkeuzes
•   niet-binaire relaties



                            4
ontwerp van een
gegevensbank

         5
•       analyse: behoeften? gegevens?
•       conceptueel ontwerp: hoog-niveau gegevensmodel
    •    gegevenstypes, relaties, beperkingen, operaties
•       transformatie naar implementatiemodel
    •    conceptueel schema volgens model van DBMS
•       fysisch ontwerp
    •    intern schema volgens model van DBMS

                              6
7
conceptueel
gegevensmodel

        8
•       bedoeling: relevant deel van de werkelijkheid beschrijven
        •     objecten + feiten
•       beschrijving = schema
    •       elke groep gebruikers heeft eigen schema
    •       alle schema's samen: infologisch schema
•       modellering gebruikt abstractie
    •       details weggelaten
    •       algemene, gemeenschappelijke eigenschappen en feiten


                                     9
•       waarom
    •     sluit nauwer aan bij realiteit dan een implementatiemodel
    •     meer betekenis van objecten dan implementatiemodellen
    •     ... minder details van implementatie
•       gebruikte model: entiteit-relatie-model
    •     objecten (entiteiten)
    •     verbanden tussen objecten (relaties)
    •     eigenschappen (attributen)
    •     waardenverzamelingen (domeinen)

                                    10
•       entiteiten 	

 	

      ∈ entiteitstype
•       relaties 	

	

 	

     ∈ relatietype
•       attributen: waarden 	

 ∈ domein


•       sleutel
    •      identificator v.e. entiteitstype / relatietype
    •      waarde van sleutel bepaalt eenduidig de entiteit / relatie


                                      11
voorbeeld:
bedrijf

         12
...




      13
•   bedrijf is georganiseerd in departementen
•   een departement heeft naam, nummer, een of meer locaties,
    departementshoofd (sinds een bepaalde datum)
•   elk departement controleert een aantal projecten
    elk project heeft naam, nummer, 1 locatie
•   voor elke werknemer
    •   naam, ID, adres, salaris, geslacht, geboortedatum, #uren per week
        besteed aan elk project, onmiddellijke overste (supervisor)
•   een werknemer hoort bij 1 departement,
    maar kan aan meerdere projecten werken die niet noodzakelijk door
    1 departement gecontroleerd worden
•   voor elke werknemer bovendien van de personen ten laste
    •   naam, geslacht, geboortedatum, relatie tot werknemer
                                      14
•   schema: mini-wereld
•   entiteit: object (fysisch of conceptueel)
    •   entiteit type: klasse
•   attribuut: eigenschap
    •   samengesteld / enkelvoudig (atomair)
    •   eenwaardig / meerwaardig	

    •   expliciet voorgesteld / afgeleid
    •   domein (= mogelijke waarden)
    •   null-waarden:
        •   "heeft geen waarde" : niet van toepassing / onbekend
    •   nesten van samengestelde / meerwaardige attributen

                                       15
16
17
18
19
sleutel

•       attribuut waarvan de waarden verschillen
    •     voor elke verschillende entiteit
    •     in elke mogelijke instantie
•       soms combinatie van attributen
•       soms meer dan één sleutel



                                    20
ontwerp van ER schema

identificeer
•   entiteitstypes
•   attributen van elk entiteitstype
•   sleutelattributen



                              21
Fname         Minit          Lname                              Number

                                      Salary           Name
          Name                                                           Locations
 Sex                     Address


Ssn           EMPLOYEE                                     DEPARTMENT



Bdate




                                                              PROJECT
               DEPENDENT


                                                    Name                  Location
Name
                                     Relationship
        Sex           Birthdate                                 Number

                                           22
relatie

•       relatietype = verzameling verbanden (relaties)
                      over entiteitstypes E1, ..., En
•       graad = aantal betrokken entiteitstypes
    •     binair, ternair, ...
•       1 entiteitstype meerdere keren: recursief relatietype
    •     vb. SUPERVISION
•       entiteitstype speelt rol in een relatie


                                     23
24
25
26
ontwerp van ER schema
identificeer
•       entiteitstypes en attributen van elk entiteitstype
    •     sleutelattributen
•       relatietypes en attributen van elk relatietype
    •     connectiviteit en deelnamebeperkingen
•       eventuele afgeleide attributen in entiteitstypes
    •     vb: aantal werknemers in een departement
                                  27
Fnam    Mini      Lnam                                                             Numbe
                          Salar                                             Nam
       Nam                                 WORKS_FO                                        Location
 Se            Addres

Ss                                               StartDat
        EMPLOYE                                                             DEPARTMEN


Bdat
                                             MANAGES
                                                              Hour          CONTROLS


                                                      WORKS_O
       SUPERVISES
                                        HAS_DEP
                                                                             PROJEC



                                                                      Nam                  Locatio
                                       DEPENDENT

                                                                                  Numbe
                    Nam
                                                        Relationshi
                                  Se      BirthDat

                                            28
beperkingen op relatietypes
•   connectiviteit ("cardinality ratio")
    •       voor binaire relatietypes: 1:1, 1:n, m:n
        •     vb. werknemer behoort bij precies één departement
    •       ternaire, ... relatietypes: meer mogelijkheden
•   deelnamebeperking
    •       totale / partiële deelname
        •     vb. moet iedereen bij een departement behoren?
    •       voor binaire relatietypes: T-T, T-P, P-P
    •       totale deelname = "bestaansafhankelijkheid"
                                        29
1:n en totaal voor employee en department
                   30
1:n en partieel voor supervisor en supervisee rol
                       31
1:1, totaal voor department en partieel voor employee

                         32
attributen van relatietypes

•   vb. aantal uren / week dat werknemer aan project werkt
•   1 : 1 ➡ attribuut kan bij een van de entiteitstypes
•   1 : n ➡ attribuut kan bij entiteitstype aan n-zijde
•   m : n ➡ attribuut kan niet bij entiteitstypes
    •    moet bij relatietype zelf
    •    vb: WORKS_ON: Hours


                                     33
Fnam         Mini      Lnam                                                                        Numbe
                                  Salar                                                     Nam
            Nam                                N          WORKS_FO         1                               Location
 Se                 Addres

 Ss                                                            StartDat
             EMPLOYE                                                                        DEPARTMEN

                                                                           1
Bdat                                           1                                                   1
                                                           MANAGES
                                                                               Hour         CONTROLS
superviso                    supervise
                                                      1
                                                                N
       1                      N                                                                    N
            SUPERVISES                                               WORKS_O          M
                                                    HAS_DEP
                                                                                             PROJEC

                                                           N
                                                                                      Nam                  Locatio
                                                   DEPENDENT

                                                                                                  Numbe
                         Nam
                                                                      Relationshi
                                          Se          BirthDat

                                                          34
zwakke entiteitstypes
•   zonder eigen sleutel
•   identificatie via entiteit van ander entiteitstype
•   identificerende entiteit = "eigenaar", identificerende relatie
•   steeds totale deelname in identificerende relatie
•   partiële sleutel
    •   identificeert entiteit binnen entiteiten met zelfde eigenaar
    •   partiële sleutel = "discriminator"
•   vb : DEPENDENT
                                   35
•       bestaansafhankelijkheid
    •     bestaan ene hangt af van bestaan van andere
    •     ondergeschikte entiteit - dominante entiteit
•       identificatieafhankelijkheid
    •     kan niet geïdentificeerd worden met eigen attributen
    •     = zwakke entiteit
    •     vb. straat ← gemeente ← land
•       vaak samen, maar niet altijd


                                      36
– ENTITEIT :
  • enkelvoud (bv. PERSOON, niet PERSONEN)
– RELATIE :
  • vervoegd werkwoord
– Attribuut
– Sleutelattribuut
– rolnaam




                             37
38
39
alternatieve notatie

(min,max) annotatie bij rol

hoe vaak kan een entiteit die rol spelen in een relatie?
              min = 0 → partieel
              min > 0 → totaal




                                   40
Fnam          Mini      Lnam                                                                    Numbe
                                  Salar                                                   Nam
              Nam                                      WORKS_FO            (4,N                          Location
 Se                   Addres
                                          (1,1

 Ss                                                           StartDat
               EMPLOYE                                                                    DEPARTMEN
                                      (0,1
                                                                         (1,1                     (0,N
Bdat
                                                         MANAGES
                               (0,1                                        hour           CONTROLS
       (0,N
                                supervise                (1,N
superviso
                                               (0,N                                               (1,1
                                                                    WORKS_O        (1,N
              SUPERVISES
                                                  HAS_DEP
                                                                                           PROJEC

                                                             (1,1
                                                                                   Nam                   Locatio
                                                 DEPENDENT

                                                                                                Numbe
                           Nam
                                                                     Relationshi
                                          Se          BirthDat

                                                        41
ontwerpkeuzes
•  attribuut verwijst naar ander entiteitstype ➡ relatie
  • vb. manager als attribuut bij DEPARTMENT
     of als relatie ts. DEPARTMENT en EMPLOYEE
• attribuut bij verschillende entiteitstypes ➡ entiteitstype
  • vb. STUDENT, INSTRUCTOR en COURSE een
     attribuut ‘Departement’ ➡ entiteit DEPARTMENT
• entiteitstype met één attribuut met één entiteitstype
   relatie ➡ attribuut
 • vb. entiteitstype DEPARTMENT met slechts één
     attribuut, en enkel relatie met STUDENT ➡attribuut


                                42
UML klasse diagram




        43
niet-binaire relaties

•       vb. van ternaire relatie: SUPPLY
    •     leverancier levert onderdelen voor project
    •     SUPPLIER, PART en PROJECT in relatie SUPPLY
•       connectiviteit en deelnamebeperking
    •     ingewikkelder, met (min, max) notatie
•       is ternaire relatie ook via binaire relaties voor te stellen?


                                    44
45
Quantity
SuppNo                                                 ProjNo



           (0,N                        (1,N
SUPPLIER          SUPPLIES_FOR                     PROJECT


                            (0,N

                                              PartNo
                     PART




                      46
een ternair relatietype vervangen door drie binaire



                                       PARTICIPATES


    SuppNo                                                              ProjNo

                                                 Quantity

   SUPPLIER             (0,N)                               (1,N)   PROJECT

                                      SUPPLIES_FOR



                                                 (0,N)


CAN_SUPPLY                                 PART                      USES




                                            PartNo


                                          47
48
49
Vragen...?

    50

More Related Content

Viewers also liked

201502010 pen ocw_les1_erik
201502010 pen ocw_les1_erik201502010 pen ocw_les1_erik
201502010 pen ocw_les1_erikErik Duval
 
Open Leren in de Praktijk
Open Leren in de PraktijkOpen Leren in de Praktijk
Open Leren in de PraktijkErik Duval
 
Presentatietechnieken
PresentatietechniekenPresentatietechnieken
PresentatietechniekenErik Duval
 
From scarcity to abundance and a helping hand from the snowflake effect
From scarcity to abundance and a helping hand from the snowflake effectFrom scarcity to abundance and a helping hand from the snowflake effect
From scarcity to abundance and a helping hand from the snowflake effectErik Duval
 
InfoVis1415: slides sessie 5, 9 March 2015
InfoVis1415: slides sessie 5, 9 March 2015InfoVis1415: slides sessie 5, 9 March 2015
InfoVis1415: slides sessie 5, 9 March 2015Erik Duval
 
InfoVis1415: slides sessie 8, 20 april 2015
InfoVis1415: slides sessie 8, 20 april 2015InfoVis1415: slides sessie 8, 20 april 2015
InfoVis1415: slides sessie 8, 20 april 2015Erik Duval
 
InfoVis1415: slides sessie 6, 23 March 2015
InfoVis1415: slides sessie 6, 23 March 2015InfoVis1415: slides sessie 6, 23 March 2015
InfoVis1415: slides sessie 6, 23 March 2015Erik Duval
 
InfoVis1415: slides sessie 4, 2 March 2015
InfoVis1415: slides sessie 4, 2 March 2015InfoVis1415: slides sessie 4, 2 March 2015
InfoVis1415: slides sessie 4, 2 March 2015Erik Duval
 
Technology that makes HUMANS smarter
Technology that makes HUMANS smarterTechnology that makes HUMANS smarter
Technology that makes HUMANS smarterErik Duval
 
InfoVis1415: slides sessie 11, 11 mei 2015
InfoVis1415: slides sessie 11, 11 mei 2015InfoVis1415: slides sessie 11, 11 mei 2015
InfoVis1415: slides sessie 11, 11 mei 2015Erik Duval
 
Information visualisation: 
Data ink design principles
Information visualisation: 
Data ink design principlesInformation visualisation: 
Data ink design principles
Information visualisation: 
Data ink design principlesErik Duval
 
eCloud newspapers
eCloud newspaperseCloud newspapers
eCloud newspapersErik Duval
 

Viewers also liked (13)

201502010 pen ocw_les1_erik
201502010 pen ocw_les1_erik201502010 pen ocw_les1_erik
201502010 pen ocw_les1_erik
 
Open Leren in de Praktijk
Open Leren in de PraktijkOpen Leren in de Praktijk
Open Leren in de Praktijk
 
Presentatietechnieken
PresentatietechniekenPresentatietechnieken
Presentatietechnieken
 
From scarcity to abundance and a helping hand from the snowflake effect
From scarcity to abundance and a helping hand from the snowflake effectFrom scarcity to abundance and a helping hand from the snowflake effect
From scarcity to abundance and a helping hand from the snowflake effect
 
InfoVis1415: slides sessie 5, 9 March 2015
InfoVis1415: slides sessie 5, 9 March 2015InfoVis1415: slides sessie 5, 9 March 2015
InfoVis1415: slides sessie 5, 9 March 2015
 
InfoVis1415: slides sessie 8, 20 april 2015
InfoVis1415: slides sessie 8, 20 april 2015InfoVis1415: slides sessie 8, 20 april 2015
InfoVis1415: slides sessie 8, 20 april 2015
 
Research2.0
Research2.0Research2.0
Research2.0
 
InfoVis1415: slides sessie 6, 23 March 2015
InfoVis1415: slides sessie 6, 23 March 2015InfoVis1415: slides sessie 6, 23 March 2015
InfoVis1415: slides sessie 6, 23 March 2015
 
InfoVis1415: slides sessie 4, 2 March 2015
InfoVis1415: slides sessie 4, 2 March 2015InfoVis1415: slides sessie 4, 2 March 2015
InfoVis1415: slides sessie 4, 2 March 2015
 
Technology that makes HUMANS smarter
Technology that makes HUMANS smarterTechnology that makes HUMANS smarter
Technology that makes HUMANS smarter
 
InfoVis1415: slides sessie 11, 11 mei 2015
InfoVis1415: slides sessie 11, 11 mei 2015InfoVis1415: slides sessie 11, 11 mei 2015
InfoVis1415: slides sessie 11, 11 mei 2015
 
Information visualisation: 
Data ink design principles
Information visualisation: 
Data ink design principlesInformation visualisation: 
Data ink design principles
Information visualisation: 
Data ink design principles
 
eCloud newspapers
eCloud newspaperseCloud newspapers
eCloud newspapers
 

More from Erik Duval

InfoVis1415: slides sessie 12, 18 mei 2015
InfoVis1415: slides sessie 12, 18 mei 2015InfoVis1415: slides sessie 12, 18 mei 2015
InfoVis1415: slides sessie 12, 18 mei 2015Erik Duval
 
Evaluation
 of information visualisation
Evaluation
 of information visualisationEvaluation
 of information visualisation
Evaluation
 of information visualisationErik Duval
 
InfoVis1415: slides sessie 9, 27 april 2015
InfoVis1415: slides sessie 9, 27 april 2015InfoVis1415: slides sessie 9, 27 april 2015
InfoVis1415: slides sessie 9, 27 april 2015Erik Duval
 
Social Media and Science a wedding made in Heaven...
 or in Hell?
Social Media and Science a wedding made in Heaven...
 or in Hell?Social Media and Science a wedding made in Heaven...
 or in Hell?
Social Media and Science a wedding made in Heaven...
 or in Hell?Erik Duval
 
A short history (and even shorter future)
 of information visualisation
A short history (and even shorter future)
 of information visualisationA short history (and even shorter future)
 of information visualisation
A short history (and even shorter future)
 of information visualisationErik Duval
 
InfoVis1415: slides sessie 7, 30 March 2015
InfoVis1415: slides sessie 7, 30 March 2015InfoVis1415: slides sessie 7, 30 March 2015
InfoVis1415: slides sessie 7, 30 March 2015Erik Duval
 
History of Human Computer Interaction
History of Human Computer InteractionHistory of Human Computer Interaction
History of Human Computer InteractionErik Duval
 
InfoVis1415: slides sessie 3, 23 Feb 2015
InfoVis1415: slides sessie 3, 23 Feb 2015InfoVis1415: slides sessie 3, 23 Feb 2015
InfoVis1415: slides sessie 3, 23 Feb 2015Erik Duval
 
InfoVis1415: slides sessie 2, 16 Feb 2015
InfoVis1415: slides sessie 2, 16 Feb 2015InfoVis1415: slides sessie 2, 16 Feb 2015
InfoVis1415: slides sessie 2, 16 Feb 2015Erik Duval
 
InfoVis1415: slides sessie 1, 10 Feb 2015
InfoVis1415: slides sessie 1, 10 Feb 2015InfoVis1415: slides sessie 1, 10 Feb 2015
InfoVis1415: slides sessie 1, 10 Feb 2015Erik Duval
 
Inleiding Human Computer Interaction
Inleiding Human Computer InteractionInleiding Human Computer Interaction
Inleiding Human Computer InteractionErik Duval
 
PenO1: Presenteren
PenO1: PresenterenPenO1: Presenteren
PenO1: PresenterenErik Duval
 
Fundamentals of HCI: intro and assignment
Fundamentals of HCI: intro and assignmentFundamentals of HCI: intro and assignment
Fundamentals of HCI: intro and assignmentErik Duval
 
20140324 chi sessie5
20140324 chi sessie520140324 chi sessie5
20140324 chi sessie5Erik Duval
 
Information Visualisation for Big Data
Information Visualisation for Big DataInformation Visualisation for Big Data
Information Visualisation for Big DataErik Duval
 
Wat na de bachelor?
Wat na de bachelor?Wat na de bachelor?
Wat na de bachelor?Erik Duval
 
CHI14: slides sessie 4
CHI14: slides sessie 4CHI14: slides sessie 4
CHI14: slides sessie 4Erik Duval
 
CHI: paper prototyping
CHI: paper prototypingCHI: paper prototyping
CHI: paper prototypingErik Duval
 

More from Erik Duval (20)

InfoVis1415: slides sessie 12, 18 mei 2015
InfoVis1415: slides sessie 12, 18 mei 2015InfoVis1415: slides sessie 12, 18 mei 2015
InfoVis1415: slides sessie 12, 18 mei 2015
 
Evaluation
 of information visualisation
Evaluation
 of information visualisationEvaluation
 of information visualisation
Evaluation
 of information visualisation
 
InfoVis1415: slides sessie 9, 27 april 2015
InfoVis1415: slides sessie 9, 27 april 2015InfoVis1415: slides sessie 9, 27 april 2015
InfoVis1415: slides sessie 9, 27 april 2015
 
Social Media and Science a wedding made in Heaven...
 or in Hell?
Social Media and Science a wedding made in Heaven...
 or in Hell?Social Media and Science a wedding made in Heaven...
 or in Hell?
Social Media and Science a wedding made in Heaven...
 or in Hell?
 
A short history (and even shorter future)
 of information visualisation
A short history (and even shorter future)
 of information visualisationA short history (and even shorter future)
 of information visualisation
A short history (and even shorter future)
 of information visualisation
 
InfoVis1415: slides sessie 7, 30 March 2015
InfoVis1415: slides sessie 7, 30 March 2015InfoVis1415: slides sessie 7, 30 March 2015
InfoVis1415: slides sessie 7, 30 March 2015
 
History of Human Computer Interaction
History of Human Computer InteractionHistory of Human Computer Interaction
History of Human Computer Interaction
 
InfoVis1415: slides sessie 3, 23 Feb 2015
InfoVis1415: slides sessie 3, 23 Feb 2015InfoVis1415: slides sessie 3, 23 Feb 2015
InfoVis1415: slides sessie 3, 23 Feb 2015
 
InfoVis1415: slides sessie 2, 16 Feb 2015
InfoVis1415: slides sessie 2, 16 Feb 2015InfoVis1415: slides sessie 2, 16 Feb 2015
InfoVis1415: slides sessie 2, 16 Feb 2015
 
InfoVis1415: slides sessie 1, 10 Feb 2015
InfoVis1415: slides sessie 1, 10 Feb 2015InfoVis1415: slides sessie 1, 10 Feb 2015
InfoVis1415: slides sessie 1, 10 Feb 2015
 
Inleiding Human Computer Interaction
Inleiding Human Computer InteractionInleiding Human Computer Interaction
Inleiding Human Computer Interaction
 
PenO1: tools
PenO1: toolsPenO1: tools
PenO1: tools
 
PenO1: Presenteren
PenO1: PresenterenPenO1: Presenteren
PenO1: Presenteren
 
Fundamentals of HCI: intro and assignment
Fundamentals of HCI: intro and assignmentFundamentals of HCI: intro and assignment
Fundamentals of HCI: intro and assignment
 
20140324 chi sessie5
20140324 chi sessie520140324 chi sessie5
20140324 chi sessie5
 
Information Visualisation for Big Data
Information Visualisation for Big DataInformation Visualisation for Big Data
Information Visualisation for Big Data
 
Wat na de bachelor?
Wat na de bachelor?Wat na de bachelor?
Wat na de bachelor?
 
Open Leren
Open LerenOpen Leren
Open Leren
 
CHI14: slides sessie 4
CHI14: slides sessie 4CHI14: slides sessie 4
CHI14: slides sessie 4
 
CHI: paper prototyping
CHI: paper prototypingCHI: paper prototyping
CHI: paper prototyping
 

Entiteit Relatie Model

  • 3. 3
  • 4. ontwerp van een gegevensbank • conceptuele gegevensmodellen • voorbeeld • E-R model • E-R diagrammen • ontwerpkeuzes • niet-binaire relaties 4
  • 6. analyse: behoeften? gegevens? • conceptueel ontwerp: hoog-niveau gegevensmodel • gegevenstypes, relaties, beperkingen, operaties • transformatie naar implementatiemodel • conceptueel schema volgens model van DBMS • fysisch ontwerp • intern schema volgens model van DBMS 6
  • 7. 7
  • 9. bedoeling: relevant deel van de werkelijkheid beschrijven • objecten + feiten • beschrijving = schema • elke groep gebruikers heeft eigen schema • alle schema's samen: infologisch schema • modellering gebruikt abstractie • details weggelaten • algemene, gemeenschappelijke eigenschappen en feiten 9
  • 10. waarom • sluit nauwer aan bij realiteit dan een implementatiemodel • meer betekenis van objecten dan implementatiemodellen • ... minder details van implementatie • gebruikte model: entiteit-relatie-model • objecten (entiteiten) • verbanden tussen objecten (relaties) • eigenschappen (attributen) • waardenverzamelingen (domeinen) 10
  • 11. entiteiten ∈ entiteitstype • relaties ∈ relatietype • attributen: waarden ∈ domein • sleutel • identificator v.e. entiteitstype / relatietype • waarde van sleutel bepaalt eenduidig de entiteit / relatie 11
  • 13. ... 13
  • 14. bedrijf is georganiseerd in departementen • een departement heeft naam, nummer, een of meer locaties, departementshoofd (sinds een bepaalde datum) • elk departement controleert een aantal projecten elk project heeft naam, nummer, 1 locatie • voor elke werknemer • naam, ID, adres, salaris, geslacht, geboortedatum, #uren per week besteed aan elk project, onmiddellijke overste (supervisor) • een werknemer hoort bij 1 departement, maar kan aan meerdere projecten werken die niet noodzakelijk door 1 departement gecontroleerd worden • voor elke werknemer bovendien van de personen ten laste • naam, geslacht, geboortedatum, relatie tot werknemer 14
  • 15. schema: mini-wereld • entiteit: object (fysisch of conceptueel) • entiteit type: klasse • attribuut: eigenschap • samengesteld / enkelvoudig (atomair) • eenwaardig / meerwaardig • expliciet voorgesteld / afgeleid • domein (= mogelijke waarden) • null-waarden: • "heeft geen waarde" : niet van toepassing / onbekend • nesten van samengestelde / meerwaardige attributen 15
  • 16. 16
  • 17. 17
  • 18. 18
  • 19. 19
  • 20. sleutel • attribuut waarvan de waarden verschillen • voor elke verschillende entiteit • in elke mogelijke instantie • soms combinatie van attributen • soms meer dan één sleutel 20
  • 21. ontwerp van ER schema identificeer • entiteitstypes • attributen van elk entiteitstype • sleutelattributen 21
  • 22. Fname Minit Lname Number Salary Name Name Locations Sex Address Ssn EMPLOYEE DEPARTMENT Bdate PROJECT DEPENDENT Name Location Name Relationship Sex Birthdate Number 22
  • 23. relatie • relatietype = verzameling verbanden (relaties) over entiteitstypes E1, ..., En • graad = aantal betrokken entiteitstypes • binair, ternair, ... • 1 entiteitstype meerdere keren: recursief relatietype • vb. SUPERVISION • entiteitstype speelt rol in een relatie 23
  • 24. 24
  • 25. 25
  • 26. 26
  • 27. ontwerp van ER schema identificeer • entiteitstypes en attributen van elk entiteitstype • sleutelattributen • relatietypes en attributen van elk relatietype • connectiviteit en deelnamebeperkingen • eventuele afgeleide attributen in entiteitstypes • vb: aantal werknemers in een departement 27
  • 28. Fnam Mini Lnam Numbe Salar Nam Nam WORKS_FO Location Se Addres Ss StartDat EMPLOYE DEPARTMEN Bdat MANAGES Hour CONTROLS WORKS_O SUPERVISES HAS_DEP PROJEC Nam Locatio DEPENDENT Numbe Nam Relationshi Se BirthDat 28
  • 29. beperkingen op relatietypes • connectiviteit ("cardinality ratio") • voor binaire relatietypes: 1:1, 1:n, m:n • vb. werknemer behoort bij precies één departement • ternaire, ... relatietypes: meer mogelijkheden • deelnamebeperking • totale / partiële deelname • vb. moet iedereen bij een departement behoren? • voor binaire relatietypes: T-T, T-P, P-P • totale deelname = "bestaansafhankelijkheid" 29
  • 30. 1:n en totaal voor employee en department 30
  • 31. 1:n en partieel voor supervisor en supervisee rol 31
  • 32. 1:1, totaal voor department en partieel voor employee 32
  • 33. attributen van relatietypes • vb. aantal uren / week dat werknemer aan project werkt • 1 : 1 ➡ attribuut kan bij een van de entiteitstypes • 1 : n ➡ attribuut kan bij entiteitstype aan n-zijde • m : n ➡ attribuut kan niet bij entiteitstypes • moet bij relatietype zelf • vb: WORKS_ON: Hours 33
  • 34. Fnam Mini Lnam Numbe Salar Nam Nam N WORKS_FO 1 Location Se Addres Ss StartDat EMPLOYE DEPARTMEN 1 Bdat 1 1 MANAGES Hour CONTROLS superviso supervise 1 N 1 N N SUPERVISES WORKS_O M HAS_DEP PROJEC N Nam Locatio DEPENDENT Numbe Nam Relationshi Se BirthDat 34
  • 35. zwakke entiteitstypes • zonder eigen sleutel • identificatie via entiteit van ander entiteitstype • identificerende entiteit = "eigenaar", identificerende relatie • steeds totale deelname in identificerende relatie • partiële sleutel • identificeert entiteit binnen entiteiten met zelfde eigenaar • partiële sleutel = "discriminator" • vb : DEPENDENT 35
  • 36. bestaansafhankelijkheid • bestaan ene hangt af van bestaan van andere • ondergeschikte entiteit - dominante entiteit • identificatieafhankelijkheid • kan niet geïdentificeerd worden met eigen attributen • = zwakke entiteit • vb. straat ← gemeente ← land • vaak samen, maar niet altijd 36
  • 37. – ENTITEIT : • enkelvoud (bv. PERSOON, niet PERSONEN) – RELATIE : • vervoegd werkwoord – Attribuut – Sleutelattribuut – rolnaam 37
  • 38. 38
  • 39. 39
  • 40. alternatieve notatie (min,max) annotatie bij rol hoe vaak kan een entiteit die rol spelen in een relatie? min = 0 → partieel min > 0 → totaal 40
  • 41. Fnam Mini Lnam Numbe Salar Nam Nam WORKS_FO (4,N Location Se Addres (1,1 Ss StartDat EMPLOYE DEPARTMEN (0,1 (1,1 (0,N Bdat MANAGES (0,1 hour CONTROLS (0,N supervise (1,N superviso (0,N (1,1 WORKS_O (1,N SUPERVISES HAS_DEP PROJEC (1,1 Nam Locatio DEPENDENT Numbe Nam Relationshi Se BirthDat 41
  • 42. ontwerpkeuzes • attribuut verwijst naar ander entiteitstype ➡ relatie • vb. manager als attribuut bij DEPARTMENT of als relatie ts. DEPARTMENT en EMPLOYEE • attribuut bij verschillende entiteitstypes ➡ entiteitstype • vb. STUDENT, INSTRUCTOR en COURSE een attribuut ‘Departement’ ➡ entiteit DEPARTMENT • entiteitstype met één attribuut met één entiteitstype relatie ➡ attribuut • vb. entiteitstype DEPARTMENT met slechts één attribuut, en enkel relatie met STUDENT ➡attribuut 42
  • 44. niet-binaire relaties • vb. van ternaire relatie: SUPPLY • leverancier levert onderdelen voor project • SUPPLIER, PART en PROJECT in relatie SUPPLY • connectiviteit en deelnamebeperking • ingewikkelder, met (min, max) notatie • is ternaire relatie ook via binaire relaties voor te stellen? 44
  • 45. 45
  • 46. Quantity SuppNo ProjNo (0,N (1,N SUPPLIER SUPPLIES_FOR PROJECT (0,N PartNo PART 46
  • 47. een ternair relatietype vervangen door drie binaire PARTICIPATES SuppNo ProjNo Quantity SUPPLIER (0,N) (1,N) PROJECT SUPPLIES_FOR (0,N) CAN_SUPPLY PART USES PartNo 47
  • 48. 48
  • 49. 49