What is a database? TDDD37 Database technology Lecture 3 Enhanced Entity-Relationship (EER) Modeling Jose M. Peña [email protected] Basic Definitions Database: Data: Mini-world: Database System Environment A collection of related data. Known facts that can be recorded and have an implicit meaning. Some part of the real world about which data is stored in a database. For example, student grades and transcripts at a university. Database Management System (DBMS): A database represents some aspect of the real world, i.e. a mini world. A database consists of a logical coherent collection of data with an underlying meaning. A database is designed, built and filled with data with respect to an underlying purpose. A software package/ system to facilitate the creation and maintenance of a computerized database. Database System: The DBMS software together with the data itself. Sometimes, the applications are also included. Database Design Process Overview Real world Model Database DBMS Query Answer Processing of queries and updates Access to stored data Physical database 6 JMP Entity-Relationship (ER) Model Entity and entity type High-level conceptual data model An overview of the database to discuss with non-database experts Easy to translate to data model of DBMS Easy Entity – a ”thing” in the real world with an independent existence Attributes – properties that describes an entity Entity type – a collection of entities that have the same set of attributes Model RegNumber ER diagram Year PersonalNumber Name Car Owner 7 Attributes 8 Constraints on attributes Simple vs composite Single-valued vs multivalued Stored vs derived Value sets (domains) of attributes Key attributes Street Street City Name City Address Name PersonalNumber Address PersonalNumber Owner Owner PhoneNumber Age PhoneNumber Age 9 Relationship type 10 Constraints on relationship types Relationship type – association among entity types Cardinality ratio – maximum number of relationship instances that an entity can participate in possible cardinality ratio: 1:1, 1: N, N:1, N:M Model RegNumber PersonalNumber Name owns N Owner Car 1 11 JMP Car owns N Owner Car owns N N 1 Owner 1 Owner Year M owns Car 12 Constraints on relationship types Constraints on relationship types Participant constraint Total participation – an entity must exist related to another entity A weak entity can be identified uniquely by being related to another entity (together with its own attributes). ”Every car must be owned by at least one owner.” PersonalNumber N M Owner Weak entity types– do not have key attibutes of their own. RegNumber Car owns name Name number N 1 team players Plays_on 13 Attributes of relationship types 14 N-ary relationships ”Store information on who owned which car and during which period of time” Example. A person works as an engineer at one company and as a gym instructor at another company. Company N SellDate Name RegNumber BuyDate Employee works at Model N M JobType works as M Year Employee K Ternary N PersonalNumber N Owner works as M owns Car Company M JobType 15 ER Notation Symbol 16 Enhanced ER (EER) Model Meaning ENTITY TYPE WEAK ENTITY TYPE RELATIONSHIP TYPE Why more? IDENTIFYING RELATIONSHIP TYPE More complex data requirements ATTRIBUTE KEY ATTRIBUTE MULTIVALUED ATTRIBUTE Example. Only some employees can use a company car, only managers have to write a monthly report, but all employees have assigned personal number, salary account and a place in the office. COMPOSITE ATTRIBUTE DERIVED ATTRIBUTE E1 E1 R 1 R N E2 TOTAL PARTICIPATION OF E2 IN R E2 CARDINALITY RATIO 1:N FOR E1:E2 IN R 17 JMP Subclass/superclass, specialization/generalization, union/category attribute and relationship inheritance 18 FirstName Name Surname PN d U Manager Commission ProjectLeader Salesman U Engineer 1 U U U Salesman o U o U d FirstName Name Employee process of defining classes Employee Engineer Manager writes 1 U uses N Car MonthlyReport PID RegNumber ReportID Software ProjectLeader 1 N SoftwareProject manages 19 20 Example 3 A taxi company needs to model their activities Union/category ProjectLeader 1 U Commission Single vs. Multiple inheritance U specialization Surname PN generalization Subclass/Superclass A subclass represents a collection of entities that is a subset of the UNION of the entities of multiple distinct superclasses CNumber PersonalNumber Person Address Company “An owner of a car is either a person or a company.” BirthDate u U 1 Owner N owns Car There are two types of employees in the company: drivers and operators. For drivers it is interesting to know the date of issue and type of the driving license, and the date of issue of the taxi driver’s certificate. For all employees it is interesting to know their personal number, address and the available phone numbers. The company owns a number of cars. For each car there is a need to know its type, year of manufacturing, number of places in the car and date of the last service. The company wants to have a record of car trips (körningar). A taxi may be picked on a street or ordered though an operator who assigns the order to a certain driver and a car. Departure and destination addresses together with times should also be recorded. 21 22 TaxiCertifDate Street PN Address Phone PostNumber A driver may have many driving licenses (types) DrivingLicenseDate Driver Town Employee DrivingLicenseType o DrivingLicenseDate U U TaxiCertifDate Driver 1 DrivingLicenseType Date Operator Type Id 1 TaxiCertifDate N assign drives 1 belongsTo DrivingLicense Körkort Driver N DepTime Destination Type N RegNumber ServiceDate DestTime ID 1 N belongsTo M Driver Places Car Date 23 JMP Type DrivingLicense N made_by TaxiCertifDate YearOfManuf Trip DeparturePlace 24 Summary Entity-Relationship (ER) diagram – a graphical way to model the world Main concepts - entity, relationship and attribute Different types of constraints Enhanced ER model 25 JMP
© Copyright 2026 Paperzz