Ghani DBMS _Entity Relationship Model

download Ghani DBMS _Entity Relationship Model

of 24

Transcript of Ghani DBMS _Entity Relationship Model

  • 8/7/2019 Ghani DBMS _Entity Relationship Model

    1/18

    Entity Relationship Model

    Abdul Ghani Khan, M.Tech (ICT)

    School of ICT, Guatam Buddha University Page 1

    Entity Relationship Model

    Conceptual Design is an important phase in designing a successful database application

    Without conceptual models, it is very difficult to communicate database designs to

    (nontechnical) users - This lack of communication may result in users data requirementsbeing missed or incorrect requirements being captured

    The Entity Relationship (ER) Model is one of the most widely used method for conceptualdesign.

    The ER Model can be neatly mapped to a Relational SchemaModule 3 Contents:

    The Entity-Relationship Model

    Conceptual Design and how conceptual design relates to the database design process Entity-Relationship (ER) Conceptual Design Method Notation Guide Example Illustrations

    Phases of Database Design:

    First step of the design process is to identify the Universe of Discourse (UoD) The database to be built will not model everything in the world, but rather some mini-world

    or Universe of Discourse.

    The UoD is the relevant portion of the real world to be modeled by the database

  • 8/7/2019 Ghani DBMS _Entity Relationship Model

    2/18

    Entity Relationship Model

    Abdul Ghani Khan, M.Tech (ICT)

    School of ICT, Guatam Buddha University Page 2

  • 8/7/2019 Ghani DBMS _Entity Relationship Model

    3/18

    Entity Relationship Model

    Abdul Ghani Khan, M.Tech (ICT)

    School of ICT, Guatam Buddha University Page 3

    Module 3 Contents:

    The Entity-Relationship Model

    Conceptual Design and how conceptual design relates to the database design process Entity-Relationship (ER) Conceptual Design Method Notation Guide Example Illustrations

  • 8/7/2019 Ghani DBMS _Entity Relationship Model

    4/18

    Entity Relationship Model

    Abdul Ghani Khan, M.Tech (ICT)

    School of ICT, Guatam Buddha University Page 4

    ERModel Basics:

    Entities Entities, Entity Sets and Entity Types

    Attributes, Keys and Value Sets

    RelationshipsRelationship Types and Sets

    Relationship Degree

    Roles andRecursive Relationships

    Relationship Constraints

    Attributes ofRelationship Types

    Entities:

    Entity Entity Sets Entity Type Attributes (Types, Keys and Value Sets)

    Real-world object distinguishable from other objects

    (e.g a student, car, job, subject, building ...)

    An entity is described using a set of attributes The same entity may have different prominence in different UoDs

    In the Company database, an employees car is of

  • 8/7/2019 Ghani DBMS _Entity Relationship Model

    5/18

    Entity Relationship Model

    Abdul Ghani Khan, M.Tech (ICT)

    School of ICT, Guatam Buddha University Page 5

    lesser importance

    In the Department of Transportations registration

    database, cars may be the most important concept

    In both cases, cars will be represented as entities;

    but with different levels of detail

    Entity Sets:

    A collection of similar entities (e.g. all employees)

    All entities in an entity set have the same set of attributes Each entity set has a key Each attribute has a domain Can map entity set to a relation easily

    Entity Type:

  • 8/7/2019 Ghani DBMS _Entity Relationship Model

    6/18

    Entity Relationship Model

    Abdul Ghani Khan, M.Tech (ICT)

    School of ICT, Guatam Buddha University Page 6

    Attributes:

    Value Sets ofAttributes:

    Value sets specify the set of values that may be assigned to a particular attribute of an entity Employee Age: Integers between 21 & 65

    Vehicle Registration Number: String of 3

    alphabets followed by 3 integers

    Value sets map to relational domains Value sets are not displayed on the ER diagram

    Null Valued Attributes:

    A particular entity may not have an applicable value for an attribute Tertiary-Degree: Not applicable for a person

    with no university education

    Home-Phone: Not known if it exists

    Height: Not known at present time

  • 8/7/2019 Ghani DBMS _Entity Relationship Model

    7/18

    Entity Relationship Model

    Abdul Ghani Khan, M.Tech (ICT)

    School of ICT, Guatam Buddha University Page 7

    Type of Null Values Not Applicable

    Unknown

    Missing

    Composite Vs. Simple Attributes:

  • 8/7/2019 Ghani DBMS _Entity Relationship Model

    8/18

    Entity Relationship Model

    Abdul Ghani Khan, M.Tech (ICT)

    School of ICT, Guatam Buddha University Page 8

    ER Model Basics:

    Entities Entities, Entity Sets and Entity Types

    Attributes, Keys and Value Sets

    Relationships Relationship Types and Sets

    Relationship Degree

    Roles and Recursive Relationships

    Relationship Constraints

    Attributes of Relationship Types

  • 8/7/2019 Ghani DBMS _Entity Relationship Model

    9/18

    Entity Relationship Model

    Abdul Ghani Khan, M.Tech (ICT)

    School of ICT, Guatam Buddha University Page 9

  • 8/7/2019 Ghani DBMS _Entity Relationship Model

    10/18

    Entity Relationship Model

    Abdul Ghani Khan, M.Tech (ICT)

    School of ICT, Guatam Buddha University Page 10

    Relationship Constraints:

    What are Relationship Constraints ?

    Constraints on relationships are determined by the UoD, which these relationships aredescribing Constraints on the relationship type limit the possible combination of entities that may

    participate in the corresponding relationship set

    Kinds of Constraints:

    What kind of constraints can be defined in the ER Model?

    Cardinality Constraints Participation Constraints

    Together called Structural Constraints

    Constraints are represented by

    specific notation in the ER diagram

  • 8/7/2019 Ghani DBMS _Entity Relationship Model

    11/18

    Entity Relationship Model

    Abdul Ghani Khan, M.Tech (ICT)

    School of ICT, Guatam Buddha University Page 11

    Example Cardinality Constraints:

    How many Employees can work in a Department?

    One employee can work in only one department

    How many Employees can be employed by a Department?

    One department can employ many employees

    How many managers can a department have?

    One department can have only one manager

    How many departments can an employee manage?

    One employee can have manage only one department

  • 8/7/2019 Ghani DBMS _Entity Relationship Model

    12/18

    Entity Relationship Model

    Abdul Ghani Khan, M.Tech (ICT)

    School of ICT, Guatam Buddha University Page 12

    Kinds of participating constraints:

    TOTAL Participation (Existence Dependency) Constraint : Every employee must work for a department

    PARTIAL Participation Constraint : Not every employee is a manager

  • 8/7/2019 Ghani DBMS _Entity Relationship Model

    13/18

    Entity Relationship Model

    Abdul Ghani Khan, M.Tech (ICT)

    School of ICT, Guatam Buddha University Page 13

  • 8/7/2019 Ghani DBMS _Entity Relationship Model

    14/18

    Entity Relationship Model

    Abdul Ghani Khan, M.Tech (ICT)

    School of ICT, Guatam Buddha University Page 14

    WeakEntities:

    Owner and weak entity must participate in a 1:N relationship type Weak entity must have total participation in the identifying relationship set (existence

    dependency)

    Weak entities normally have a Partial Key, which is a set of attributes that uniquely identifyweak entities related to the same owner entity

    Not every existence dependency results in a weak entity !

  • 8/7/2019 Ghani DBMS _Entity Relationship Model

    15/18

    Entity Relationship Model

    Abdul Ghani Khan, M.Tech (ICT)

    School of ICT, Guatam Buddha University Page 15

  • 8/7/2019 Ghani DBMS _Entity Relationship Model

    16/18

  • 8/7/2019 Ghani DBMS _Entity Relationship Model

    17/18

    Entity Relationship Model

    Abdul Ghani Khan, M.Tech (ICT)

    School of ICT, Guatam Buddha University Page 17

    Example Illustrations:

    Project Management Course Administration Recruitment Company Database

    Note how different (interpretations of) semantics change the ER Diagram

  • 8/7/2019 Ghani DBMS _Entity Relationship Model

    18/18

    Entity Relationship Model

    Abdul Ghani Khan, M.Tech (ICT)

    School of ICT, Guatam Buddha University Page 18

    Company Schema (Relational):

    EMPLOYEE[Ssn, Fname, Minit, Lname, Bdate, Address, Sex, Salary , SuperSsn ] DEPARTMENT[ Dnumber, Dname MGRSSN, MgrStart ] PROJECT[Pno, PName, Plocation, Dnum ] DEPENDENT[ ESSN,DepName, Sex, BirthDate, Relationship ] WORKS_ON[ ESSN, PNo, Hours ] DEPT_LOCS[ DNumber, Dlocation ]