Fundamentals/ICY: Databases 2012/13 WEEK 5 John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK.

Slides:



Advertisements
Similar presentations
Chapter # 4 BIS Database Systems
Advertisements

Fundamentals/ICY: Databases 2013/14 WEEK 4: Monday Intro to tables, etc. John Barnden Professor of Artificial Intelligence School of Computer Science University.
Entity Relationship (E-R) Modeling Hachim Haddouti
Entity Relationship (ER) Modeling
Entity Relationship (ER) Modeling
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 4 Entity Relationship (ER) Modeling.
Fundamentals/ICY: Databases 2013/14 Week 6: Monday John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham,
Chapter 4 Entity Relationship (E-R) Modeling
Entity Relationship (ER) Modeling
Entity Relationship (ER) Modeling
Entity Relationship (E-R) Modeling
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 David M. Kroenke Database Processing Tenth Edition Chapter 5 Data.
Chapter Five Data Modeling with the Entity-Relationship Model.
Chapter 4 Entity Relationship (ER) Modeling
Database Systems: Design, Implementation, and Management Tenth Edition
Mapping ERM to relational database
Entity Relationship Modeling Objectives: To illustrate how relationships between entities are defined and refined. To know how relationships are incorporated.
3 Chapter 3 Entity Relationship (E-R) Modeling Database Systems: Design, Implementation, and Management, Fifth Edition, Rob and Coronel.
Intro to Maths for CS: 2013/14 Sets (2) – OPTIONAL MATERIAL John Barnden Professor of Artificial Intelligence School of Computer Science University of.
Chapter 7 Data Modeling with Entity Relationship Diagrams Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
ITEC 3220M Using and Designing Database Systems Instructor: Prof. Z.Yang Course Website: 3220m.htm
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Fundamentals/ICY: Databases 2010/11 WEEK 5 John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK.
Chapter 5 Entity Relationship (ER) Modelling
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Fundamentals/ICY: Databases 2012/13 WEEK 7 John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK.
Fundamentals/ICY: Databases 2013/14 Week 10 –Monday –Normalization, contd John Barnden Professor of Artificial Intelligence School of Computer Science.
Database Design Principles – Lecture 3
Fundamentals/ICY: Databases 2012/13 WEEK 3 John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK.
Database Systems: Design, Implementation, and Management Tenth Edition Chapter 4 Entity Relationship (ER) Modeling.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 4 Entity Relationship (ER) Modeling.
Chapter 4 Entity Relationship (ER) Modeling.  ER model forms the basis of an ER diagram  ERD represents conceptual database as viewed by end user 
Fundamentals/ICY: Databases 2010/11 WEEK 3 John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK.
Fundamentals/ICY: Databases 2012/13 WEEK 11 – 4 th Normal Form (optional material) John Barnden Professor of Artificial Intelligence School of Computer.
Database Design – Lecture 5 Conceptual Data Modeling – adding attributes.
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
1 A Demo of Logical Database Design. 2 Aim of the demo To develop an understanding of the logical view of data and the importance of the relational model.
Fundamentals/ICY: Databases 2013/14 WEEK 9 –Monday John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham,
3 & 4 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Keys Consists of one or more attributes that determine other.
Database Systems: Design, Implementation, and Management Ninth Edition Chapter 4 Entity Relationship (ER) Modeling.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 4 ENTITY RELATIONSHIP (ER) MODELING Instructor Ms. Arwa Binsaleh 1.
Database Design – Lecture 4 Conceptual Data Modeling.
Fundamentals/ICY: Databases 2013/14 WEEK 9 –Friday John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham,
Fundamentals/ICY: Databases 2013/14 Week 5: Monday John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham,
Fundamentals/ICY: Databases 2012/13 Week 4 John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK.
Fundamentals/ICY: Databases 2013/14 Week 4: Friday John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham,
Fundamentals/ICY: Databases 2013/14 Week 11 – Monday – relations, ended. John Barnden Professor of Artificial Intelligence School of Computer Science University.
Fundamentals/ICY: Databases 2012/13 WEEK 9 John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK.
Department of Mathematics Computer and Information Science1 CS 351: Database Management Systems Christopher I. G. Lanclos Chapter 4.
ERD :: 19 / 1 / Entity-Relationship (ER) Modeling. ER Modeling is a top-down approach to database design. Entity Relationship (ER) Diagram –A.
Entity Relationship Modeling
Let try to identify the conectivity of these entity relationship
TMC2034 Database Concept and Design
Chen’s Type Guidance.
Tables and Their Characteristics
Database Design – Lecture 4
Fundamentals/ICY: Databases 2010/11 WEEK 6
ERD :: 19 / 1 / Entity-Relationship (ER) Modeling. ER Modeling is a top-down approach to database design. Entity Relationship (ER) Diagram –A.
Chapter 4 Entity Relationship (ER) Modeling
Database Systems: Design, Implementation, and Management Tenth Edition
Review of Week 1 Database DBMS File systems vs. database systems
Chapter 4 Entity Relationship (ER) Modeling
Entity-Relationship Diagram (ERD)
Fundamentals/ICY: Databases 2013/14 WEEK 6 - Friday
John Barnden Professor of Artificial Intelligence
Database Management system
Database Management system
Entity Relationship (ER) Modeling
Chapter # 4 Entity Relationship (ER) Modeling.
Presentation transcript:

Fundamentals/ICY: Databases 2012/13 WEEK 5 John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK

Reminder of Week 4

1:1 Connectivity between Tables PERS-IDNAMEPHONEEMPL IDAGE Chopples E Blurp E Rumpel E BigglesE PHONETYPESTATUS officeOK homeFAULT homeOK mobileUNPAID Note: the representation is still asymmetric in that the People table mentions phones but not vice versa – symmetry would create extra redundancy. NB: Biggles has no phone listed, and has no person recorded. Suggests a possible reason for not combining such tables. 1:1: that is, no more than one phone allowed per person, and vice versa. People Phones

1:M Connectivity between Tables PERS-IDNAMEPHONEEMPL IDAGE Chopples E Blurp E Rumpel E Dunston E EMPL IDEMPL NAMEADDRESSNUM EMPLSSECTOR E48693BTBT House, London, … 1,234,5678Private TCOM E85704Monmouth School Hereford Rd, Monmouth, … 245Private 2E E22561University of Birmingham Edgbaston Park Rd, …. 3023Public HE People Organizations More than one employee allowed per organization, but no more than one employer per person. NOTE direction of use of the foreign key. Why so??

New for Week 5

M:N Connectivity between Tables uIF we represent M:N connectivity in a similar way to 1:M, then we can expect that l in the People table: some people will have each several employers listed l or in the Organizations table: an organization will have several employees listed l or both. uThis is a problem. Why?

M:N Connectivity between Tables, contd. uBecause of this problem, an M:N relationship is usually broken up into two 1:M relationships. uThis means introducing an extra “bridging” or “linking” or “composite” entity type (hence table) to stand between the two original ones.

ORGANIZATIONS EMPLOYMENTS each = person-id + organzn-id possibly plus other attributes M:N -- a person may be employed by more than one organization and an organization may employ more than one person PEOPLE does not have an EMPL ID attrib. does not have a PERS ID attrib

M:N Connectivity between Tables using a Bridging Entity Type PERS-IDNAMEAGE Chopples Blurp Rumpel Dunston29 EMPL IDEMPL NAMEADDRESSNUM EMPLSSECTOR E48693BTBT House, London, … 1,234,5678Private TCOM E85704Monmouth School Hereford Rd, Monmouth, … 245Private 2E E22561University of Birmingham Edgbaston Park Rd, …. 4023Public HE People Organizations PERS-IDEMPL IDSTART E E E E EmploymentsEmploymentsEmploymentsEmployments

Strong (or Identifying) Relationships uA relationship from entity type A to entity type B, mediated by having A’s primary key (PK) as a foreign key in B, is strong when B’s PK contains A’s PK. (incl. the case of B’s PK just being A’s PK). So, B entities are defined in terms of A entities. uE.g., A = Customers, B = Dependents, where l A’s PK is: CUST_ID l B’s PK is: CUST_ID, FIRST_NAME, CONNECTION. l So a PK value in B could be ( , Mary, child), meaning that this entity is the child called Mary of person in the Customer table.

a Strong Relationship CUST-IDNAMEPHONEEMPL IDAGE Chopples E Blurp E Rumpel E Dunston E CUST-IDFIRST NAMECONNECTIONLIVES_WITH Johncivil partnerTRUE MarychildFALSE MaryspouseFALSE DavidchildTRUE Customers (the “A” type) Dependents (the “B” type) Strong relationship going from A to B (we could say: “B is strongly dependent on A”)

Weak (or Non-Identifying) Relationships uA relationship is weak when it isn’t strong! So, most relationships are weak. uNote that strength/weakness is directional: the People to Dependents relationship (above) is strong, but the Dependents to People relationship is weak. uExercise: Can a relationship be weak in both directions? uExercise: Can a relationship be strong in both directions?

Weak Entity Types R uA weak entity type E is one such that there is a relationship R from some other entity type F to E that satisfies the following two conditions: l R l R is strong. R l E is existence-dependent on F via R. R That is, an E entity e can only exist in the database if some F entity in the database bears relationship R to e. R —1 R This actually just means that R —1 (the R relationship but in the E to F direction) is mandatory.

Weak Entity Types, contd. uSo on a previous slide, Dependents is weak, because there is a strong relationship to it from Customers, and Dependents is existence-dependent on Customers via this relationship. l Mary’s existence in the database as a member of Dependents relies on the existence of customer in the database. But this doesn’t mean Mary would vanish from the world if customer left the database or even if that customer were to vanish from the world. And indeed Mary could herself be an entity in type Customers, and could remain so even if left the DB or really vanished from the world.

Strong Entity Types uA strong entity type is one that is not weak! …. uSo, in particular, any entity that receives only weak relationships from other entity types is strong. uSo the usual case is for an entity type to be strong. uAnd any entity type that is not existence-dependent on anything is strong.

Mental Exercises for You uWhat about the Employments bridging type we introduced? uAlthough it might look at first as though a strong relationship necessarily implies existence dependence, it doesn’t. Why not? uOne entity type can be existence-dependent on another without therefore being weak. Why?

Entity Relationship (ER) Model(s) and Diagrams (ERMs and ERDs)

The Entity Relationship Model uIntroduced by Chen in 1976 uMost widely used “conceptual model” of DBs. u“The ER model” : general meaning = just the idea of thinking of things as composed of entities, attributes and relationships. uWe also say that applying this approach in a particular case gives rise to an “ER model” of the specific environment of interest. uDiagrams based on the/a model are a widely accepted and adopted graphical approach to database design. / uThe/an ER model has nothing intrinsically to do with diagrams!!! Let alone any specific sort of diagram!!!

A Conceptual Model / uER model that provides high-level, manager/user- friendly view of the database uBasis for identification and description of main data objects and relationships, avoiding details

Entity Relationship Diagrams (ERDs) uAn ER model of an environment forms the basis of an ER diagram (ERD) or several ERDs. uThere are several markedly different styles of ERD, and for each main style there are several variants. l And the style in the module handouts will differ somewhat from that in the textbooks and these lectures uAn ERD depicts (some of) the ER model’s entity types, attributes and relationships, and (depending on the diagram style) varying amounts of other info such as connectivities, cardinalities, keys, weakness, …

Quick Flavour of Two Styles of Diagram

The Completed Tiny College ERD

Relationships: The Basic Chen ERD-let

Relationships: The Basic Crow’s Foot ERD-let

Caution uIn previous two diagrams, each relationship was mandatory in both directions. uBut saying “1:1”, “1:M” or “M:N” does not of itself imply mandatoriness in either direction. In particular, don’t be deceived by the “1” here – it’s not a minimum. uWe will see in a minute how to draw optional (non- mandatory) relationships.

A Model for Tiny College

1:1 Relationship Between PROFESSOR and DEPARTMENT (mandatory in both directions)

1:M Relationship Between PAINTER and PAINTING (mandatory in both directions)

Tables for that 1:M Relationship

M:N Relationship between STUDENT and CLASS (both ways mandatory): preliminary ERD (conceptual level)

Conversion to Two 1:M Relationships (towards “logical” level)

A Bridge (or Composite) Entity Type uIts table is called a linking table (or bridging table) uIts primary key is composed of the primary keys of each of the entity types to be connected uThose keys are also foreign keys in the bridge type uLinking table may contain multiple occurrences of each foreign key value uMay also contain additional attributes that play no role in the bridging as such

Direct Impln of M:N Relationship between STUDENT and CLASS

Converting the M:N Relationship into Two 1:M Relationships

Connectivity and Cardinality in an ERD

Relationship Participation uOptional [in a particular direction, X to Y]: l an X entity occurrence does not require a corresponding Y entity occurrence l i.e. the minimum number of Ys per X is 0 uMandatory [in a particular direction, X to Y]: l an X entity occurrence requires a corresponding Y entity occurrence l i.e. the minimum number of Ys per X is 1 or more

Drawing Optionality NOTE: the dashing of the line is NOT because of the optionality, but because of weakness

The Chen Representation of the Invoicing Problem

The Crow’s Foot Representation of the Invoicing Problem

The Attributes of the STUDENT Entity

Attributes

Weak Entity Types in ERDs

A Weak Entity in an ERD

A Weak (Non-Identifying) Relationship