+ All Categories
Home > Documents > Chapter 9 ERD

Chapter 9 ERD

Date post: 30-May-2018
Category:
Upload: evyx
View: 219 times
Download: 0 times
Share this document with a friend

of 16

Transcript
  • 8/9/2019 Chapter 9 ERD

    1/16

    1

    Chapter 9: Building an Information Architecture

    ERD

    = Entity Relationship Diagram

    niks te maken met processen, maar met structuur van de data

    - The ERD is a data modeling tool- The ERD defines all data that are input, stored, transformed and produce d within aninformation system- The ERD focuses solely on data. Unlike a DFD, the processes that transform thedata are irrelevant in an ERD- It is a preliminary stage towards defining the database structure, independent of software that will be used to implement the database, by means of a formal modelsuch as the relational model

    - There are 3 basic elements in an ERD:o Entities

    o things about which we seek informationo Attributes (= kenmerken)

    o The data we collect about the entitieso Relationships

    o Represents associations between 2 entitieso Provide the structure needed to draw information from multiple entitieso Are evaluated in both directions

    - An entity instance is an individual occurence of an entity

    Entityo A thing or object of significance, whether rea l or imagined, about which

    information is needed to be maintainedo An object in the real world that is relevant to the information systemo Can be real or abstract

    o Book, author o Loan, sales

    o In an E-R-diagram, an entity is shown by a box with a nameo Naming convention

    o Using a singular noun that, if possible, is known to the user o Written in capitalso E.g CUSTOMER in een rechthoek getekend

    Attributeo Is a properly or characteristic of an entity that is of interest to the organizationo Can be classifies as identifiers or descriptorso An identifier (key, primary key) uniquely identifies an instance of an entityo A descriptor describes a non-unique characeristic of an entityo An attribute is written in singular in lower case in an ellipse connected to the

    entityo Its nor necessary to show attributes

  • 8/9/2019 Chapter 9 ERD

    2/16

    2

    - Simple (or atomic) attributeo Cannot be broken down into smaller components

    - Composite attributeo Can be broken down into smaller componentso Provide flexibility to users

    (Country moet city zijn)

    EX!! Indien je ERD moet gebruiken maar er is te weinig informatie gewoonopschrijven dat er te weinig informatie is

    - Single-valued attributeo For each entity instance, the attribute has only one value- Multivalued attributeso An attribute that may take on more than one value for a particular entity

    instanceo Hobby persoon kan meerdere hobby's hebben (dus er zijn meerdere

    attributen) in dubbele elipse tekenen

    - Derived attributeo An attribute whose value can be calculated form related attribute valueso Age kan ook berekend worden via Birthdate (Age: je kunt een veld niet

    automatisch laten verhogen wanneer?)

  • 8/9/2019 Chapter 9 ERD

    3/16

    3

    - Identifying attributeo = identifier, primary keyo Attribute (or combination of attributes) that uniquely identifies each individual

    instance of the entity- Composite key atomic key- Candidate key

    o An attribute or set of attributes that uniquely identifies individual occurrences

    of an entity type- Atomic identifiers

    - Composite identifiers

    - Criteria for selecting identifierso Choose an identifier that will not change its value over the life of each instance

    of the entityo Choose an identifier that is guaranteed to have valid values and not be null (or

    empty, or unknown)o Avoid the use of so-called intelligent identifiers whose structure indicates

    classifications, locations, and so ono Consider substituting atomic attribute surrogate identifiers for large compositeidentifiers

    Simple Examples

  • 8/9/2019 Chapter 9 ERD

    4/16

    4

    - We can give you a report with all the cars, containing registration number, licenseplate, brand, model and colour

    o

    Eerst nagaan of er van elk zelfstandig naamwoord meerdere mogelijkhedenzijn bv is er maar 1 soort auto of meerdere?o Car in vierkant entityo Elipse: RegNr, Colour, Model, Brand, License plate attributeno (onderstreepte = authentieke sleutel; hier: RegNr )

    - From each member we know his full name, address, phone and his ageo Entiteit: member o Attributen: MemberID, Last name, First name, Birth date, Phone, Address

    (verder opsplitsen in: Street, City, Postal code)

    - Each library can give you a list of books with ISBN, title, author, editor and year of

    publicationo Entity: booko Attributen: ISBN, Title, Author, Editor, Year of publicationo Old books???o Attribute author???? One author??? desnoods in dubbele elipse tekenen

    om aan te duiden dat er meerdere attributen (auteurs) kunnen hebben; watmet andere boeken van auteur? Prijzen?

    geen attribuut maar ook een entiteit (aangezien je er meer gegevensvan kunt verwerken)

    o Attribute editor??? geen attribuut maar een entiteit op zich

    - We sell products. A product has a unique productcode, a productname and a price.We also keep track of the price history (the price fluctuations): each time a productbecomes cheaper or more expensive, we write down the date of the new price andthe price itself. When you want to know the current price, we search for the price withthe most recent date.

    o Entity: Producto Attributes: Product code, Product name, Price historyo Price multi-valued attribute (double ellipse)

    o Price history in double ellipse, that disintegrates in Price and Date

  • 8/9/2019 Chapter 9 ERD

    5/16

    5

    - From each person we know his full name, address, birth date and phone. Somepersons do not have a phone number. Choose an identifier

    o Entity: Producto Attribute: PersonID, Phone, Birth date, Address ( Street, City, Postal code)o Candidate keys:

    o PersonIDo Last name + First name + Phone???o Last name + First name + Birth date???o Last name + First name + Birth date + Phone???

    Entity Relationship Diagram

    - Relationshipo Represents an association between 2 or more entities (see 'simple examples'

    books)o Entiteit = een object waarover we gegevens verzamelen

    - Binary relationships

    Optional relationships = 0 Mandatory relationships = 1 of |Relaties uit 2 entiteiten staan niet los van elkaar (entity A heeft relatie met entity B enomgekeerd)

    o One-to-many relationship kom je praktisch altijd tegen in een ERD

    - Cardinality of a relationshipo Actual number of instances in the relationshipo Cardinality is usually expressed as one or many

    - Existence of a relationshipo Indicates whether the relationship is optional or mandatoryo Mandatory = an instance of an entity must always be associated with at least

    one instance of the related entityo Relationship between mother and son

    Mandatory for son (must have / had a mother)o Optional = some instances of an entity are not associated with instances of the

    related entityo Relationship between mother and son

    Optional for mother (all her children might be daughters)

    - A foreign key is a referential constraint between 2 tables

  • 8/9/2019 Chapter 9 ERD

    6/16

    6

    - The foreign key identifies a column or a set of columns is one (referencing) tablethat refers to a column or set of columns in another (referenced) table. The columnsin the referencing table must be the primary key in the referenced table- The referencing and referenced table may be the same table, i.e the foreign keyrefers back to the same table- A table may have multiple foreign keys

    2 entities: an employee and a functionForeign key: FunctionIDNot every employee has a functionID

    Op figuren:1 of | = mandatory0 = optional

    Tekening = fout 1 aan de kant van de customer en 0 aan de kant van de order Foreign key: CustomerID

  • 8/9/2019 Chapter 9 ERD

    7/16

    7

    - Unary relationshipo Relationship between the instances of a single entityo = recursive relationship

    Hoogste in rang rapporteert aan niemand tegen klok in lezen

    a) Rechthoeken bepaald in Access tabellen Attributes bepaald in velden van tabelb) Werknemer die aan niemand rapporteert vakje managerID (= sleutel) blijft leeg

    In handboek: verplichte relaties worden aangeduid door 2 streepjes

    Ruit: ook gebruikt om de naam van een relatie weer te geven hoeft bij ERD niet op examen

    Examen: zeker optionele en verplichte relaties aanduiden

    - Many-to-many relationship

  • 8/9/2019 Chapter 9 ERD

    8/16

    8

    Een medewerker gaat aan meerdere projecten meewerken. Aan 1 project gaan meerdere medewerkers werken.

    Bestaat niet in ERD, kan je niet creren in Access Oplossen door twice one-to-many

    - Many-to-many = twice one-to-many

    Je gaat een extra entiteit introduceren (een tussenentiteit)Nieuwe project = Project detailsMedewerkers koppelen aan project, en projecten koppelen aan medewerkers

    Dit kan een databank perfect verwerken

    Als nu niet elke werknemer aan een project kan worden gekoppel d, dan wil datzeggen dat er een 0 gekoppeld wordt aan de tussenentiteit.

    Aan elk project moet er minstens 1 werknemer worden gekoppeld, dus dit is eenverplichte relatie.

    - Many-to-many relationship

  • 8/9/2019 Chapter 9 ERD

    9/16

    9

    Employee: enkelvoudige sleutel

    Project details: samengestelde sleutel (samenvoeging van de 2 sleutels van deentiteiten van waaruit je vertrekt)EmployeeID and Project ID apart from Project details: foreign / referrential keyProjectID of Project, EmployeeID of Employee, EmployeeID and ProjectID together of Project details: primary key

    - Checking for redundant relationshipso One of these relationships is redundant

    o Has Inhabitants on the right already exists through Contains and Hasinhabitants on the left

    - But

  • 8/9/2019 Chapter 9 ERD

    10/16

    1

    3 entiteiten: stad, land en een persoon Een land heeft meerdere steden 1 op veelrelatie Een stad heeft meerdere inwoners 1 op veelrelatie Een land heeft meerdere inwoners 1 op veelrelatie

    Rechterkant is overbodig want linkerkant wijst zichzelf uit niet opnemen intekeningen (dus weglaten)

    - In this example all relationships are necessary if a cricket player is not necessarilyan inhabitant of the country

  • 8/9/2019 Chapter 9 ERD

    11/16

  • 8/9/2019 Chapter 9 ERD

    12/16

    1

    - A product and a supplier

    Bv merkproduct komt maar van 1 leverancier

    0 aan kant van product, dwz dat je in je systeem leveranciers hebt die nog nietsgeleverd hebben

    Kan ook:Bv veevoeder kan door meerdere leveranciers geleverd worden

    1 want product moet geleverd worden door leverancier

    - A magazine has several articles. E ach article starts and ends on a specificpage.

    Mogelijke entiteiten: magazine, article en page Een entiteit bevat altijd meerdere elementen page = entiteit MAAR je moet een

    entiteit kunnen beschrijven adhv verschillende attributen geen entiteit maar eenattribuut (Start Page en End Page) (een entiteit moet meer d an 1 attribuut bevatten

    je moet dus meer dan 1 element kunnen vermelden)

    Artikel wordt in verschillende magazines gepubliceerdStart page en End page zijn publishing details doordat de start - en eindpagina in

    elk magazine verschillend is

    Andere mogelijke oplossing:

    Teacher Teacher courses

    Course

    Supplier Product0

    0Supplier Supplier detail

    Product

  • 8/9/2019 Chapter 9 ERD

    13/16

  • 8/9/2019 Chapter 9 ERD

    14/16

    1

    A company publishes vacancies. Each vacancy requires a set of skills (Fluent inEnglish, Working with Word, Programming in C#, ). For each skill the requiredlevel is indicated (basic, expert, ). A skill can be requested for in severalvacancies. A vacancy is published during a limited period: it starts and ends on acertain date. Choose appropriate identifiers

    Kandidaat entiteiten: vacancies, skills, periodPeriod geeft aanleiding tot 2 attributen: de StartDate en de EndDate van depublicatieWij staan aan kant van het bedrijf (= op drachtgever) company is hier 1 uniekbedrijf geen entiteit

    Relatie tussen vacancies en skills: many-to-many

    Primary keys indien niet uitdrukkelijk vermeld: naam vermelden van entiteit en IDachterplakkenCombinatie VacanciesID en SkillsID is uniek = foreign key>< tegenspreken van ervoor!! (wat juist?)

    Skill = definitie van een skill Acquired skills = skill die opgenomen moeten worden in de vacancy

    Elke skill gaat een unieke ID (code) krijgen bv kennis Engels, werken met word, ...met verschillende levels (basis, gevorderd, ...)Bv Kennis Engels basis = code 1, kennis Engels gevorderd = code 2, ...

    Niet vermelden op ERD! Nieuwe tussenentiteit: Niveau (daarop aangeven of basiskennis, gevorderde, ... is

    vereist)

    ERD: bij een veel op veel relatie mag dit niet op 1 lijn staan moet dimensie inzitten

    - A company implements projects for customers

  • 8/9/2019 Chapter 9 ERD

    15/16

    1

    A company implements projects for customers. Each project gets a project leader and a team of project members. All these people are personnel of the company. Notall personnel can be assigned to projects (e.g a secretary). The project leader of project A can be a team member of project BEach project gets a start and a due date. When the project is finished, it gets an enddate.

    With the system following questions must be answered:o How many projects are implemented at this moment?o Who are the project leaders of the current projects?o How many projects have not met their deadline?o Which employees are assigned to more than 2 projects at the same time?

    Wij staan aan de kant van het bedrijf

    Welke entiteiten? Project, project team, project leader, personnelProject attributen: Start Date, Delivery Date, Deadline

    Relatie project personnel: many-to-many

    Bij project team: ofwel geen medewerker en geen rol en wel projectleader, ofwelmedewerker en geen projectleader en geen rol, ofwel rol en geen projectleader engeen medewerker

    je kan als projectleader geen andere rol meer opnemen

    Project team personnel: optional relationsh ip (0) want niet elk personeelslid werktmee aan een project (bv secretariaat)

    Vragen:a) Je kan een blanco hebben bij u delivery dateb) Blanco DeliveryDate en attribuut rol bij project teamc) Selectie van projecten onder DeliveryDate zijn groter dan di e van Deadlined) Kijk naar relatie personeel project team. Project overstaande met DeliveryDate(is blanco) geeft aan welke werknemers aan meer dan 2 projecten werken

    O efening: inschrijven in 1 DR

    Een student schrijft in voor n of meerdere opleiding en. Om het diploma te behalenschrijft hij/zij per academiejaar in voor een set opleidingsonderdelen (max. 72

    0

    Customer

    Project

    Project team

    Personnel

    StartDate

    DeliveryDate

    Deadline

    Role / functionOF

    Projectleader

  • 8/9/2019 Chapter 9 ERD

    16/16

    1

    studiepunten). De student behaalt een credit indien hij meer dan 10/20 behaalt. Hijkan onder bepaalde voorwaarde een tolerantie inzetten voor een 8 of 9/20.Opleidingsonderdelen met een score


Recommended