Entity/Relationship Modelling

Slides:



Advertisements
Similar presentations
ER Model For a college DB
Advertisements

Entity Relationship Diagrams
Entity-Relationship (ER) Modeling
Chapter 2.1 V3.1 Napier University Dr Gordon Russell
ENTITY RELATIONSHIP MODELLING
Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Entity Relationship (ER) Modeling
Copyright © 2015 Pearson Education, Inc. Database Design Chapters 17 and
Revised by Ivor Perry Sept Introduction to Data Modelling.
1 Data Modelling Which data to include in the database.
Entity/Relationship Modelling
Entity Relationship Model Chapter 6. Basic Elements of E-R Model Entity Object of the real world that stores data. Eg. Customer, State, Project, Supplier,
Entity-Relationship Modeling I The cautious seldom err. Confucius.
DeSiamorewww.desiamore.com/ifm1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
Module Title? Data Base Design 30/6/2007 Entity Relationship Diagrams (ERDs)
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
DATABASEMODELSDATABASEMODELS  A database model ◦ defines the logical design of data. ◦ Describes the relationships between different parts of data.
Database Systems Lecture # 7 8 th Feb, Conceptual and Logical Design Person buys Product name pricenamessn Conceptual Model: Relational Model: (plus.
MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj ER Model Lecture 1 © Akhilesh Bajaj, 2000, 2002, 2003, 2004.
1.  An introduction to data modelling  The purpose of data modelling  Modelling data relationships 2.
Entity-Relationship (ER) Modelling ER modelling - Identify entities - Identify relationships - Construct ER diagram - Collect attributes for entities &
Lecture 4 Conceptual Data Modeling. Objectives Define terms related to entity relationship modeling, including entity, entity instance, attribute, relationship,
DeSiamorePowered by DeSiaMore1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
Database Design 3: Advanced Data Modeling Concepts CS 320.
Msigwaemhttp//:msigwaem.ueuo.com/1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
Data modeling using the entity-relationship model Chapter 3 Objectives How entities, tuples, attributes and relationships among entities are represented.
 An entity-relationship diagram (ERD) is a specialized graphic that illustrates the interrelationships between entities in a database.
Data Modelling Using Entity-Relationship (ER) Model
advanced data modeling
INTRODUCTION TO DATA MODELING CS 260 Database Systems.
Entity/Relationship Modelling. Entity Relationship Modelling In This Lecture Entity/Relationship models Entities and Attributes Relationships Attributes.
1 Information System Analysis Topic-3. 2 Entity Relationship Diagram \ Definition An entity-relationship (ER) diagram is a specialized graphic that illustrates.
1 CS 430 Database Theory Winter 2005 Lecture 3: A Fifty Minute Introduction to Data Modeling.
DATA SCIENCE MIS0855 | Spring 2016 Designing Data
Rationale Databases are an integral part of an organization. Aspiring Database Developers should be able to efficiently design and implement databases.
Database Designsemester Slide 1 Database Design Lecture 7 Entity-relationship modeling Text , 7.1.
ENTITY-RELATIONSHIP MODELLING. Objectives: How to use Entity–Relationship (ER) modelling in database design. Basic concepts associated with ER model.
Entity-Relationship Data Model
Entity Relationship (E-R) Model
Database Design Chapters 17 and 18.
Entity Relationship Modeling
Data Modeling Using the ERD
Entity-Relationship Model
ER model Ashima Wadhwa.
Entity-Relationship Model
Case Studies: Data Modeling
Entity-Relationship Model
Chapter -3- Data Modeling Using the Entity-Relationship Model
Entity-Relationship Modelling
Entity-Relationship Modeling
ER Modeling Case Studies
بسم الله الرحمن الرحيم.
Entity Relationship Diagrams
Entity-Relationship Modelling
MIS2502: Data Analytics Relational Data Modeling
Entity Relationship Model
Data Modeling for Database Design 2
Database Systems Instructor Name: Lecture-9.
Database Modeling using Entity Relationship Model (E-R Model)
Fundamentals of Databases CSU 07203
ER Modeling Case Studies
Database Design Hacettepe University
ER Modeling Case Studies
Chapter 7: Entity-Relationship Model
Entity-Relationship Diagram (ERD)
Lesson Objectives Aims You should know about: 1.3.2:
MIS2502: Data Analytics Relational Data Modeling 2
Entity Relation Model Tingting Zhang.
Database Management system
Entity-Relationship Data Model
Presentation transcript:

Entity/Relationship Modelling (Based on slides by Natasha Alechina, University of Nottingham)

Entity Relationship Modelling In This Lecture Entity/Relationship models Entities and Attributes Relationships Attributes E/R Diagrams Entity Relationship Modelling

Entity Relationship Modelling Database Design We’ve created database tables before – useful to have a more formal look at how we design them as well (not strictly required for the class assignment, but may be useful) Need to consider What tables, keys, and constraints are needed? What is the database going to be used for? Entity Relationship Modelling

Entity/Relationship Modelling E/R Modelling is used for conceptual design Entities - objects or items of interest Attributes - facts about, or properties of, an entity Relationships - links between entities Example In a University database we might have entities for Students, Modules and Lecturers. Students might have attributes such as their ID, Name, and Course, and could have relationships with Modules (enrolment) and Lecturers (tutor/tutee) Entity Relationship Modelling

Entity/Relationship Diagrams E/R Models are often represented as E/R diagrams that Give a conceptual view of the database Are independent of the choice of DBMS Can identify some problems in a design Lecturer ID Name Course Tutors Student Studies Module Entity Relationship Modelling

Entity Relationship Modelling Entities Entities represent objects or things of interest Physical things like students, lecturers, employees, products More abstract things like modules, orders, courses, projects Entities have A general type or class, such as Lecturer or Module Instances of that particular type, such as Diarmuid Ó Muirgheasa is an instance of Lecturer Attributes (such as name, email address) Entity Relationship Modelling

Entity Relationship Modelling Diagramming Entities In an E/R Diagram, an entity is usually drawn as a box with rounded corners The box is labelled with the name of the class of objects represented by that entity Lecturer ID Name Course Tutors Student Studies Module Entity Relationship Modelling

Entity Relationship Modelling Attributes Attributes are facts, aspects, properties, or details about an entity Students have IDs, names, courses, addresses, … Modules have codes, titles, credit weights, levels, … Attributes have A name An associated entity Domains of possible values Values from the domain for each instance of the entity they belong to Entity Relationship Modelling

Diagramming Attributes In an E/R Diagram attributes may be drawn as ovals Each attribute is linked to its entity by a line The name of the attribute is written in the oval Lecturer ID Name Course Tutors Student Studies Module Entity Relationship Modelling

Entity Relationship Modelling Relationships Relationships are an association between two or more entities Each Student takes several Modules Each Module is taught by a Lecturer Each Employee works for a single Department Relationships have A name A set of entities that participate in them A degree - the number of entities that participate (most have degree 2) A cardinality ratio Entity Relationship Modelling

Entity Relationship Modelling Cardinality Ratios Each entity in a relationship can participate in zero, one, or more than one instances of that relationship This leads to 3 types of relationship… One to one (1:1) Each lecturer has a unique office One to many (1:M) A lecturer may tutor many students, but each student has just one tutor Many to many (M:M) Each student takes several modules, and each module is taken by several students Entity Relationship Modelling

Diagramming Relationships Relationships are links between two entities The name is given in a diamond box The ends of the link show cardinality Lecturer ID Name Course Tutors Student Studies Module One Many Entity Relationship Modelling

Removing M:M Relationships Many to many relationships are difficult to represent We can split a many to many relationship into two one to many relationships An entity represents the M:M relationship Enrolment Student Module In Has Student Module Studies Entity Relationship Modelling

Entity Relationship Modelling Making E/R Models To make an E/R model you need to identify Enitities Attributes Relationships Cardinality ratios from a description General guidelines Since entities are things or objects they are often nouns in the description Attributes are facts or properties, and so are often nouns also Verbs often describe relationships between entities Entity Relationship Modelling

Entity Relationship Modelling Example A university consists of a number of departments. Each department offers several courses. A number of modules make up each course. Students enrol in a particular course and take modules towards the completion of that course. Each module is taught by a lecturer from the appropriate department, and each lecturer tutors a group of students Entity Relationship Modelling

Entity Relationship Modelling Example - Entities A university consists of a number of departments. Each department offers several courses. A number of modules make up each course. Students enrol in a particular course and take modules towards the completion of that course. Each module is taught by a lecturer from the appropriate department, and each lecturer tutors a group of students Entity Relationship Modelling

Example - Relationships A university consists of a number of departments. Each department offers several courses. A number of modules make up each course. Students enrol in a particular course and take modules towards the completion of that course. Each module is taught by a lecturer from the appropriate department, and each lecturer tutors a group of students Entity Relationship Modelling

Entity Relationship Modelling Example - E/R Diagram Entities: Department, Course, Module, Lecturer, Student Department Course Module Lecturer Student Entity Relationship Modelling

Entity Relationship Modelling Example - E/R Diagram Each department offers several courses Offers Department Course Module Lecturer Student Entity Relationship Modelling

Entity Relationship Modelling Example - E/R Diagram A number of modules make up each courses Offers Department Includes Course Module Lecturer Student Entity Relationship Modelling

Entity Relationship Modelling Example - E/R Diagram Students enrol in a particular course Offers Department Includes Course Module Lecturer Enrols In Student Entity Relationship Modelling

Entity Relationship Modelling Example - E/R Diagram Students … take modules Offers Department Includes Course Module Lecturer Takes Enrols In Student Entity Relationship Modelling

Entity Relationship Modelling Example - E/R Diagram Each module is taught by a lecturer Offers Department Includes Teaches Course Module Lecturer Takes Enrols In Student Entity Relationship Modelling

Entity Relationship Modelling Example - E/R Diagram a lecturer from the appropriate department Offers Employs Department Includes Teaches Course Module Lecturer Takes Enrols In Student Entity Relationship Modelling

Entity Relationship Modelling Example - E/R Diagram each lecturer tutors a group of students Offers Employs Department Includes Teaches Course Module Lecturer Takes Enrols In Tutors Student Entity Relationship Modelling

Entity Relationship Modelling Example - E/R Diagram Offers Employs Department Includes Teaches Course Module Lecturer Takes Enrols In Tutors Student Entity Relationship Modelling

Entities and Attributes Sometimes it is hard to tell if something should be an entity or an attribute They both represent objects or facts about the world They are both often represented by nouns in descriptions General guidelines Entities can have attributes but attributes have no smaller parts Entities can have relationships between them, but an attribute belongs to a single entity Entity Relationship Modelling

Entity Relationship Modelling Example We want to represent information about products in a database. Each product has a description, a price and a supplier. Suppliers have addresses, phone numbers, and names. Each address is made up of a street address, a city, and a postcode. Entity Relationship Modelling

Example - Entities/Attributes Entities or attributes: product description price supplier address phone number name street address city postcode Products, suppliers, and addresses all have smaller parts so we can make them entities The others have no smaller parts and belong to a single entity Entity Relationship Modelling

Entity Relationship Modelling Example - E/R Diagram Price Description Product Street address Name Supplier Address City Phone number Postcode Entity Relationship Modelling

Example - Relationships Each product has a supplier Each product has a single supplier but there is nothing to stop a supplier supplying many products A many to one relationship Each supplier has an address A supplier has a single address It does not seem sensible for two different suppliers to have the same address A one to one relationship Entity Relationship Modelling

Entity Relationship Modelling Example - E/R Diagram Price Description Product Has A Street address Has A Name Supplier Address City Phone number Postcode Entity Relationship Modelling

One to One Relationships Some relationships between entities, A and B, might be redundant if It is a 1:1 relationship between A and B Every A is related to a B and every B is related to an A Example - the supplier- address relationship Is one to one Every supplier has an address We don’t need addresses that are not related to a supplier Entity Relationship Modelling

Redundant Relationships We can merge the two entities that take part in a redundant relationship together They become a single entity The new entity has all the attributes of the old one a x A B b y c z AB z y x a c b Entity Relationship Modelling

Entity Relationship Modelling Example - E/R Diagram Price Description Product Has A Name Supplier City Phone number Postcode Street address Entity Relationship Modelling

Entity Relationship Modelling Making E/R Diagrams From a description of the requirements identify the Entities Attributes Relationships Cardinality ratios of the relationships Draw the E/R diagram and then Look at one to one relationships as they might be redundant Look at many to many relationships as they might need to be split into two one to many links Entity Relationship Modelling

Entity Relationship Modelling Debugging Designs With a bit of practice E/R diagrams can be used to plan queries You can look at the diagram and figure out how to find useful information If you can’t find the information you need, you may need to change the design Enrolment Student Module In Has How can you find a list of students who are enrolled in Database systems? Entity Relationship Modelling

Entity Relationship Modelling Debugging Designs ID (3) For each instance of Enrolment in the result of (2) find the corresponding Student Enrolment Student Module In Has Name ID (2) Find instances of the Enrolment entity with the same Code as the result of (1) Code Code (1) Find the instance of the Module entity with title ‘Database Systems’ Title Entity Relationship Modelling