+ All Categories
Home > Documents > Chapter 2 EC601

Chapter 2 EC601

Date post: 02-Jun-2018
Category:
Upload: dauz-joho
View: 221 times
Download: 0 times
Share this document with a friend

of 43

Transcript
  • 8/10/2019 Chapter 2 EC601

    1/43

  • 8/10/2019 Chapter 2 EC601

    2/43

  • 8/10/2019 Chapter 2 EC601

    3/43

    Entity is an object of the real world which can

    store data and can be defined with clarity. Example : something that exist physically such

    as individual, place, article or something that

    exists conceptually such as an event or concept

    in a user environment. Each entity has attributes, or a particular

    properties that describe the entities.

    Example: student (entity) name Aminah has

    attributes or properties of her own Student

    Reg. No, name and grade

    A particular value of an attribute, such as 93

    for the grade is a value of the attribute.

  • 8/10/2019 Chapter 2 EC601

    4/43

    Sometimes, the value of an attribute is

    unknown or missing and sometimes a value isnot applicable.

    In such cases, the attribute can have the

    special value of null.

    Example : until the teacher grades anassignment , the team grade is missing or null..

  • 8/10/2019 Chapter 2 EC601

    5/43

    ENTITY EXAMPLE

    invidual Customer, Worker, Supplier

    venue / place District, State, Country

    object Stationary, Furniture

    event Purchase Order, Booking,Sale

    concept Project, Account, Unit

  • 8/10/2019 Chapter 2 EC601

    6/43

    The ER model consist of different types ofentities.

    The existence of an entity may depends onthe existence of one or more other entities.

    In other words : an entity is said to beexistence dependent.

    Entities based on their characteristic areclassified as follows :

    Strong entitiesWeak entities

    Recursive entities

    Composite entities

  • 8/10/2019 Chapter 2 EC601

    7/43

    Weak Entity Type

    An entity set that does not have sufficient

    attribute to form a primary key is termed as

    weak entity.

    It is also a type that is existence-dependent onsome other entity type.

    Strong Entity Type

    Entity set that has a primary key is strong entity

    set. Entity type that is notexistence-dependent on

    some other entity type.

  • 8/10/2019 Chapter 2 EC601

    8/43

    Recursive Entity

    -A recursive entity is one in which a relation canexist between occurrences of the same entity

    set. This occurs in a unary relationship.

    Unary relationship is relationship between the

    instances of a single entity type. (bothparticipants in the relationship are the same

    entity)

    Eg: employee to manager. Ones manager is, in most

    cases also an employee with a manager of his own.

    EMPLOYEE

    Employee_ID Name Birthdate Manager_ID

  • 8/10/2019 Chapter 2 EC601

    9/43

    Composite Entity-If a Many to Many relationship exist we must

    create a bridge entity to convert it into 1 to

    Many.

    Bridge entity composed of the primary keys

    of each of the entities to be connected.

    The bridge entity is known as a composite

    entity. A composite entity is represented by a

    diamond shape with in a rectangle in an ER

    Diagram.

  • 8/10/2019 Chapter 2 EC601

    10/43

    Eg: in a school database, a TEACHER can

    teach many different SUBJECTs and aSUBJECT can be taught by many differentTEACHERs.

    Such situations are modelled using a

    composite entity, which is usuallydecomposed to several one to manyrelationship later in the modelling process.

    The composite entity must contain theprimary keys of the associated entities as its

    foreign keys. Represent using a diamond in a rectangle.

  • 8/10/2019 Chapter 2 EC601

    11/43

    SUBJECTTEACHER teachteach

    LNameFName

    Ext

    Subj_code

  • 8/10/2019 Chapter 2 EC601

    12/43

  • 8/10/2019 Chapter 2 EC601

    13/43

  • 8/10/2019 Chapter 2 EC601

    14/43

    Entity Set

    An entity may be concrete such as a person,book etc or may be abstract such as account,loan etc.

    The ER model refers to a specific table row as anentity instance or entity occurrence.

    Collection of similar entities (Entity Set) oftencorresponds to a table.

    Each entity set has a key.

    All entities in an entity set have the same set ofattributes. Thus entity set is a set of entities ofthe same type that share the same properties orattributes.

    An entity is represented bya rectangle containing the entity name, which isa noun usually written in capital letters.

  • 8/10/2019 Chapter 2 EC601

    15/43

    A description or an entity characteristic isknown as an attribute.

    Used to differentiate object in an entity.

    The symbol used to represent attribute isoval and connected to entities by lines

  • 8/10/2019 Chapter 2 EC601

    16/43

  • 8/10/2019 Chapter 2 EC601

    17/43

    Explain the attribute and a value set.

    Explain E-R model.

    Explain the following relationship types in E-

    R model : 1:1 (one to one)

    1:M (one to many)

    M:N (many to many)

    Draw E-R model based on a given situation.

  • 8/10/2019 Chapter 2 EC601

    18/43

    Simple Attribute has only one component,exist independently and cannot be brokenup. Eg: name or gender

    Composite Attribute comprises of manycomponents, each one existingindependently. Eg: address with sub attributes such as

    o house_no,

    o road_no,

    o town

    o postcode

  • 8/10/2019 Chapter 2 EC601

    19/43

    Solitary Valued Attributeis an attribute thatconsists of only a single value. (matric_no, ic_no )

    Multi-Valued Attribute is an attributeconsisting of many values. ( telephone no)

    Derived Attributeis an attribute where its

    values is derived from the value of relatedattributes or set of other attributes.( ageattribute derived from the date of birth )

  • 8/10/2019 Chapter 2 EC601

    20/43

    [ composite attribute ]

    [ multi-valued attribute]

    [ derived attribute]

    [ simple attribute]

    STUDENT

    matricno

    age

    address

    dateofbirth

    gender

    studentname

    postcode

    garden

    road

    houseno

    phoneno

    specialty

  • 8/10/2019 Chapter 2 EC601

    21/43

    You share many relationships with members

    of your family.

    For instance, you and your mother are

    relatedYou have only one mother, but she

    may have several children.

    You and your siblings are related you may

    have many brothers and sisters and, of

    course, they'll have many brothers and

    sisters as well. If you're married, both you and your spouse

    have a spouseeach otherbut only one at a

    time.

  • 8/10/2019 Chapter 2 EC601

    22/43

    So in database, relationship is basically a set

    of meaningful association between tables

    A relationship exists between two database

    tables when one table has a foreign key thatreferences the primary key of another table.

  • 8/10/2019 Chapter 2 EC601

    23/43

    E-R Model is a conceptual and semantic

    model of a database that captures meanings

    rather than an actual implementation.

    Use E-R model to get a high-level graphicalview of essential components of your

    database and how they are related

    So, the E-R Model is viewed as set of

    Entities Relationships among the entities

  • 8/10/2019 Chapter 2 EC601

    24/43

    Symbols used in E-R Diagram

    Entityrectangle

    Attribute oval

    Relationship diamond

    Link - line

  • 8/10/2019 Chapter 2 EC601

    25/43

    TYPES INER MODEL

    ONE TOONE

    ONE TOMANY

    MANY TOMANY

  • 8/10/2019 Chapter 2 EC601

    26/43

  • 8/10/2019 Chapter 2 EC601

    27/43

    One to one 1 :1

    This type of relationship takes place when a

    single occurrence of an entity is related to just

    one occurrence of a second entity.

    For example, a ROOF covers one BUILDING; aBUILDING is covered by one ROOF.

    In other words, both tables can have only one

    record on either side of the relationship. Each

    primary key value relates to only one (or no)record in the related table.

  • 8/10/2019 Chapter 2 EC601

    28/43

  • 8/10/2019 Chapter 2 EC601

    29/43

  • 8/10/2019 Chapter 2 EC601

    30/43

    One-to-many 1:M

    Relationships occur when each record in TableA

    may have many linked records in TableB but

    each record in TableB may have only onecorresponding record in TableA.

    This relationship is similar to the one between

    you and a parent. You have only one mother, but

    your mother may have several children.

  • 8/10/2019 Chapter 2 EC601

    31/43

  • 8/10/2019 Chapter 2 EC601

    32/43

  • 8/10/2019 Chapter 2 EC601

    33/43

    Many to manyM: N

    Relationship where multiple rows from table A can

    correspond to multiple rows in table B.

    An example of such a relationship is a schoolwhere teachers teach students.

    In most schools each teacher can teach multiple

    students and each student can be taught by

    multiple teachers.Other example; if you have several siblings, so do

    your siblings (have many siblings).

  • 8/10/2019 Chapter 2 EC601

    34/43

  • 8/10/2019 Chapter 2 EC601

    35/43

    EXAMPLE II

    A customer is associated with several (possibly 0)

    loans via borrower A loan is associated with several (possibly 0)

    customers via borrower

  • 8/10/2019 Chapter 2 EC601

    36/43

  • 8/10/2019 Chapter 2 EC601

    37/43

  • 8/10/2019 Chapter 2 EC601

    38/43

    The relationship type orderconnects

    entities chemicaland supplier.

    The relationship is many-to-many because

    each chemical can be from several suppliers

    and each supplier has a number of

    chemicals.

  • 8/10/2019 Chapter 2 EC601

    39/43

    An order has a purchase date, amount, and

    total cost as well as the chemical and

    supplier information.

    Thus, orderhas attributes PurchaseDate,

    amount, and TotalCostthat we cannot

    appropriately associate

    with chemicalor supplier.

  • 8/10/2019 Chapter 2 EC601

    40/43

  • 8/10/2019 Chapter 2 EC601

    41/43

    Describe the relationship for each E-R model. Eg 1:

    Situation : An employee has a single resume;

    each resume belongs to only one person.

    Description : The 1:1 relationship reflects the rules that

    an employee can have only one resume and that

    a resume can belong to only one employee.

  • 8/10/2019 Chapter 2 EC601

    42/43

    Eg 2:

    Description: A department can have many employees,

    but that each individual employee can work

    for only one department.

    1 M

  • 8/10/2019 Chapter 2 EC601

    43/43

    Eg 3:

    Description: An employee can work on more than one project,

    and a project can have more than one employee assigned.

    M1


Recommended