lecture6 dbms

Upload: pankajparashar

Post on 14-Apr-2018

241 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 Lecture6 DBMS

    1/18

    Entity relation Diagram

  • 7/27/2019 Lecture6 DBMS

    2/18

    1.2

    IntroductionStrong & Weak Entity Sets An entity set that has a primary key is termed as a Strong entity set. If an entity set may

    not have sufficient attributes to form a primary key. Then these entity sets are termed as a Weak entity set. For example Employee entity set has three attributes, Employee_ID, Department andProject and any one of them can act as a key attribute or primary key; further we haveanother entity set Dependent having three attributes as Name, Age and Sex. In Dependententity set there is no such attribute, which can act as a key attribute so this, is known as

    weak entity set and Employee is called as Strong entity set. The primary key of the strong entity set forms the primary key of a weak entity set on which the weak entity set isexistence dependent.

    Have Employee

    Employee_ID

    Department

    Project

    Dependent

    Age Sex

    Name

  • 7/27/2019 Lecture6 DBMS

    3/18

    1.3

  • 7/27/2019 Lecture6 DBMS

    4/18

    1.4

  • 7/27/2019 Lecture6 DBMS

    5/18

    1.5

  • 7/27/2019 Lecture6 DBMS

    6/18

    1.6

    Attributes Can be Attached to a Relationship Set

    If a relationship set has also some attributes associated with

    it, then we link these attributes to that relationship set.

    Customer

    Customer Name

    Social SecurityNo

    Customer Street

    Customer City

    Borrow er

    Balance

    Account

    Account_No

    Access_Date

  • 7/27/2019 Lecture6 DBMS

    7/181.7

    Role Indicators A relationship might associate several entities for the same underlying entity set. Then an additional role indicator is used in the E-R diagram to

    distinguish the similar entities. The function that an entity plays in a relationship is called its Role . Forexample, the relationship W orks-As might be ordered pairs of E mployee (first is Team Member, second is Project Leader).

    Project Leader

    WorksA

    s

    Employee

    Telephone

    Emp_ID Emp_Name

    Team Member

  • 7/27/2019 Lecture6 DBMS

    8/181.8

    Non-Binary (Ternary) Relationships Diagram specifies that a customer may have several loans, and that loanmay belong to several different customers.

    Arrow pointing to branch indicates that each customer-loan pair isassociated with a specific bank branch.

    Amount

    Loan

    Loan_No

    CLB

    Branch

    Branch Name

    Branch City

    Phone

    Customer

    Customer Name

    Social SecurityNo

    Customer Street

    Customer City

  • 7/27/2019 Lecture6 DBMS

    9/181.9

    Enhanced ER (EER) Model The ER modeling concepts discussed earlier are sufficient for representing many database schemas for traditional database applications, which mainly include data-processing applications in business and industry.

    The newer applications of database technology include databases forengineering design and manufacturing (CAD/CAM), telecommunications,

    images and graphics, multimedia, data mining, data warehousing,geographic information systems (GIS), and databases for indexing the World Wide Web among many other applications.

    To represent these requirements as accurately and clearly as possible, theER model can be enhanced to include these concepts, leading to theEnhanced-ER or EER model.

  • 7/27/2019 Lecture6 DBMS

    10/181.10

    The EER model includes all the modeling concepts of the ER modeland the concepts of Subclass and Superclass and the relatedconcepts of Specialization and Generalization .

    One more concept EER model is Category , which is used torepresent a collection of objects. It is the union of objects of differententity types.

  • 7/27/2019 Lecture6 DBMS

    11/181.11

    SpecializationAn entity set may include subgroupings of entities that are distinct in someway from other entities in the set. A subset of entities within an entity set may

    have attributes that are not shared by all the entities in the entity set.Ex. An entity set person may be classified as

    Customer Employee

    Each person types is described by a set of attributes that includes all theattributes of entity set person plus some additional attributes.

    The process of designating sub groupings within an entity set is calledspecial izat ion.

    A person can be a employee, a customer or both.

  • 7/27/2019 Lecture6 DBMS

    12/181.12

    Person

    Employee Customer

    Person_id name street city

    salary Credit_rating

    officer teller secretary

    Office_number

    Station_number

    Hours_worked

    Hours_worked

    Fig. Specialization and generalization

  • 7/27/2019 Lecture6 DBMS

    13/181.13

    Generalization:

    A generalization is simply inversion of specialization. In other words a Generalization is acontainment relationship that exist between a higher level entity set to one or more lower

    level entity set.To create a generalization the attributes must be given a common name and representedfrom the higher level to lower level.

    Higher and lower level entity sets are also called as superc lass and subc l a s s .

    In nutshell, the specialization process allows us to do the following 1. Define a set of subclasses of an entity type. 2. Establish additional specific attributes with each subclass. 3. Establish additional specific relationship types between eachsubclass and other entity types or other subclasses.

  • 7/27/2019 Lecture6 DBMS

    14/181.14

    Aggregation:

    the limitation of E-R model is that it cannot express relationships amongother relationships.

    Ex. We want to record managers for tasks performed by an employee at abranch (I.e. we want to record managers for(employee, branch , job)combinations.

    Assume there is an entity set manager.create a quaternary relationshipmanages

    works_on

    manages

    branchemployee

    manager

    job

  • 7/27/2019 Lecture6 DBMS

    15/181.15

    Aggregation is an abstraction through which relationships are treated as higher levelentities.

    Here the relationship set works_on (relating entity set employee, branch and job) act ashigher level entity set called works_on. Now we can create the binary relationship manages

    between works_on and manager to represent who manages the task.

    works_on

    manages

    branchemployee

    manager

    job

    E-R diagram with aggregation

  • 7/27/2019 Lecture6 DBMS

    16/181.16

    Reduction of an E-R schema to Tables: -

    Tabular representation of strong entity sets : - Let E be a strong entity setwith descriptive attributes a

    1, a

    2, a

    3, --------, a

    n. We represent this entity by a table

    called E with n distinct columns, each of which corresponds to one of the attributesof E. Each row in this table corresponds to one entity of the entity set E.

    Ex. the loan entity set has two attributes, loan_number andamount.

    Loan_number Amount

    L-17L-18L-23L-25L-27L-11L-19

    1000200035004000300015002500

    Loan Table

  • 7/27/2019 Lecture6 DBMS

    17/181.17

    Tabular Representation of weak entity set: - Let A be a weak entity set with attributes a 1,a2, a 3, ----, a m. Let B be the strong entity set on which A is dependent. Let the primary key of B consist of attributes b 1, b2, b3, ----, b n. We represent the entity set A by a table called A withone column for each attribute of the set

    {a1, a2, a3, -----,a m} U {b 1, b2, b3, ----, b n}

    Ex. payment entity set has three attributes payment_number, payment_date and payment_amount. The primary key of the loan entity set on which payment is dependent islaon_number.

    Loan_number Payment_number Payment_date Payment_amount

    L-17L-18L-23L-25L-27L-11L-19

    57

    1215131110

    10-05-200015-06-200010-04-199915-12-199905-04-200012-11-199829-10-2001

    500150030001500100020001500

  • 7/27/2019 Lecture6 DBMS

    18/18

    Assignment

    Q. Explain Strong and Weak Entity Sets.