Semantic Data Modeling

Embed Size (px)

Citation preview

  • 7/31/2019 Semantic Data Modeling

    1/30

    Semantic Modeling 1CIS

    Semantic Data Modeling

    oWhat is Conceptual Data Modeling

    oEntity-Relationship (E-R ) Modeling

    oLimitations of E-R Modeling

    oObject-oriented Modeling: Another semantic

    model (discussed later in this course)

  • 7/31/2019 Semantic Data Modeling

    2/30

  • 7/31/2019 Semantic Data Modeling

    3/30

    Semantic Modeling 3CIS

    Bridge the Gap

    STUDENT( ID, Name, Age, Address, GPA )

    INSTRUCTOR ( Emp#, Name, Rank, Dept )

    COURSE ( Course#, Credits, Title )

    CLASS ( Emp#, ID, Course#, Time, Room )

    STUDENT( ID, Name, Age, Address, GPA )

    INSTRUCTOR ( Emp#, Name, Rank, Dept )

    COURSE ( Course#, Credits, Title )

    CLASS ( Emp#, ID, Course#, Time, Room )

  • 7/31/2019 Semantic Data Modeling

    4/30Semantic Modeling 4CIS

    Data Semantics

    oStatic Information

    u Data -- Entities

    u Associations -- Relationships among entities

    oDynamic Information

    u Activities -- Operations/transactions

    u Integrity constraints -- Business rules/regulations and data meanings

  • 7/31/2019 Semantic Data Modeling

    5/30Semantic Modeling 5CIS

    Conceptual Data Model Revisited

    A conceptual data model consists of:o A collection of formal concepts

    o A set of usage rules

    Different model has different modeling capability

    Conventional (Logicaldata modeling)

    Conventional (Logical

    data modeling)

    Semantic datamodeling

    Semantic datamodeling

    Object-Oriented

    data modeling

    Object-Orienteddata modeling

    -- Hierarchical

    -- Network-- Relational

    -- E-R

    -- EER-- etc.

  • 7/31/2019 Semantic Data Modeling

    6/30Semantic Modeling 6CIS

    E-R Modeling

    o Introduced by Peter Chen in 1976

    oBasic modeling concepts:

    u Entities, entity types, and attributes

    u Relationships

    Instructor OfficeAssigned1 1

    DepartmentWorks_for

    N

    1

    Teaches

    N

    M

    Course

    Date

    Language

    Emp#

    Name

    FName

    MInit LName

    Time

    Location

    Date

  • 7/31/2019 Semantic Data Modeling

    7/30Semantic Modeling 7CIS

    E-R Notation

    Entity Relationship

    Attribute Primary Key

  • 7/31/2019 Semantic Data Modeling

    8/30Semantic Modeling 8

    CIS

    Entities

    oAn entity is a conceptual objectoPhysically exists

    4Usually a noun in requirement specification

    CIS 2010CIS 3730

    Jose Alice Steve

    Acct CIS

    Class

    Student

    Department

  • 7/31/2019 Semantic Data Modeling

    9/30Semantic Modeling 9

    CIS

    Entity Types

    oA collection of similar entities

    oAn abstraction of "physical" entities

    4A noun in requirement specifications

    4Having "independent" meaning

    DepartmentDepartment

    StudentStudent

    CourseCourse

    AcctCISJose

    Alice

    Steve

    CIS 3730CIS 2010

  • 7/31/2019 Semantic Data Modeling

    10/30Semantic Modeling 10

    CIS

    Weak Entity Types

    oCan't exist in DB independently

    oMust be identified by its owner

    u Owner entity type

    u Identify relationship

    u Partial key

    u Total participation

    Student Registers Car

    Date

    1N

    Color PNumParkingLot#

  • 7/31/2019 Semantic Data Modeling

    11/30

  • 7/31/2019 Semantic Data Modeling

    12/30

    Semantic Modeling 12CIS

    Key Attributes

    One or a group of attributes that can uniquely identifyindividual entities of an entity type

    u A key refers to one or a group of attributes as a whole

    u A key attribute is a component attribute of a key

    u Key changes with data semantics

    An entity type may have several qualified keys

    u Primary key -- One of the candidate keys

    u Alternate key - Candidate keys not used as the primary key

    u Secondary key -- An identifier of records with similar properties of interest

    4The primary key attribute(s) is(are) underlined

  • 7/31/2019 Semantic Data Modeling

    13/30

    Semantic Modeling 13CIS

    More Attributes

    StudentStudent

    id

    age

    name

    degrees

    FnameMname

    Lname

    oSimple attributeContains atomic values only

    oComposite attribute

    Has component attributes

    __________________________________

    oSingle-valued attribute

    Has exactly one value per entity

    oMulti-valued attribute

    Contains repeating values per entity

    __________________________________

    oDerived attribute

    Attribute values computed by means of

    other attributes

    SalesrepSalesrep

    Fname

    Mname

    Lname

    EmpNo

    CommRate

    CommEarned

  • 7/31/2019 Semantic Data Modeling

    14/30

    Semantic Modeling 14CIS

    Relationships

    Associations among entitiesu Relationships -- Associations among entities

    4Usually a verb in requirement specification

    Occurrence Diagram or Semantic Net

    CourseStudent

    Takes

    Joseph

    Alice

    Sue

    Tom

    Peter. . .

    CIS2010

    CIS3210

    CIS3215

    CIS3730

    CIS8140

    . . .

    Student CourseTakes

  • 7/31/2019 Semantic Data Modeling

    15/30

    Semantic Modeling 15CIS

    Relationship Degrees

    The number of entity types associated with that relationship.Each entity in a relationship is known as aparticipant.

    Unary

    Supervises

    EmployeeEmployeeEmployeeEmployee DepartmentDepartmentWork

    Binary

    n-aryTernary

    ProjectProject

    Part

    PartSupply

    SupplierSupplier

  • 7/31/2019 Semantic Data Modeling

    16/30

    Semantic Modeling 16CIS

    N-ary Relationships

    oA link must associate with all participants

    oCardinality is with respect to individual relationships

    4A N-ary relationship is not equivalent to N binary

    relationships

    Salesperson Order

    Customer

    ships

    N

    M 1

  • 7/31/2019 Semantic Data Modeling

    17/30

    Semantic Modeling 17CIS

    Relationship Attribute

    oDescribes the association

    4A adverb or noun in requirement specification

    Instructor Courseteaches

    sect# time

    dateroom#

  • 7/31/2019 Semantic Data Modeling

    18/30

    Semantic Modeling 18CIS

    Relationship Cardinality

    How entities are connectedthrough a relationship

    u One-to-One -- An entity ofE1 is

    connected to at most one entity ofE2

    and vice versa.

    u One-to-Many -- An entity ofE1 may

    be connected to one or more entities

    ofE2, but an entity ofE2 can only be

    mapped to at most one entity ofE1.u Many-to-Many -- An entity ofE1

    may be linked to one or more entities

    ofE2, and vice versa.

    [ ][ ]

    [ ]...

    abc

    ...

    xyz

    ...

    E1 E2R

    1 1

    [ ]

    [ ][ ]...

    a

    bc...

    x

    yz

    ...

    1 M

    ...

    abc...

    xyz

    ...

    M N

  • 7/31/2019 Semantic Data Modeling

    19/30

  • 7/31/2019 Semantic Data Modeling

    20/30

    Semantic Modeling 20CIS

    Recursive Relationship called

    Superviseswith Role Names

  • 7/31/2019 Semantic Data Modeling

    21/30

    Semantic Modeling 21CIS

    Entities associated through two distinctRelationships with Role Names

  • 7/31/2019 Semantic Data Modeling

    22/30

    Semantic Modeling 22CIS

    Participation ConstraintsLetR be a relationship type involves entity type E as a

    participant. If every instance ofE participates in at least one

    instance ofR, then the participation is said to betotal; other

    wise it is said to be partial [Date, 2004]

    oPartial (optional)

    participation

    An entity ofE does not have to be

    mapped to another entity through therelationship.

    oTotal (mandatory)

    participation

    Every entity ofE must be connected

    through the relationship to other entity

    ( or entities ).

    WriterWriter

    Publishes

    BookBook

    M

    1

    St t l C t i t

  • 7/31/2019 Semantic Data Modeling

    23/30

    Semantic Modeling 23CIS

    Structural Constraints

    Main type of constraint on relationships is calledmultiplicity.

    Multiplicity - number (or range) of possibleoccurrences of an entity type that may relate to asingle occurrence of an associated entity typethrough a particular relationship.

    Represents policies (called business rules)established by user or company.

    M lti li it

  • 7/31/2019 Semantic Data Modeling

    24/30

    Semantic Modeling 24CIS

    Multiplicity

    Teaches TakesFaculty Course Student

    (1,45)(0,4) (1,1) (?,?)

    O h E R M d l

  • 7/31/2019 Semantic Data Modeling

    25/30

    Semantic Modeling 25CIS

    Other E-R Models

    Entity 1 Entity 2Relationship

    RelationshipEntity 1 Entity 2

    attr. 1attr. 2

    RelationshipEntity 1 Entity 2( 1:m ) ( 0:5 )

    P d C f E R

  • 7/31/2019 Semantic Data Modeling

    26/30

    Semantic Modeling 26CIS

    Pros and Cons of E-R

    Emp#, Name, Address

    Salary, Skill

    Advantagesu Simple and easy to understand.

    u Very popular.

    u Semantic richer than classical datamodels.

    Disadvantages:

    uNot a formally defined data model.

    u Deals with some integrity constraints.

    u Difficult to distinguish entities from

    relationships.

    u Has redundant modeling information.

    Project

    Manager

    Project

    Dependent

    Project

    MemberWorks-on

    m-has

    Manageshas

    Emp#, Name, Address

    Salary, Skill

    ID, NameAddress

    Birth-date

    I A R l ti hi

  • 7/31/2019 Semantic Data Modeling

    27/30

    Semantic Modeling 27CIS

    Is-A RelationshipoGeneralization and specialization hierarchy

    u Supertypes -- Hide the differences of subtypes

    u Subtypes -- Reveal specific properties

    Person

    Student Staff

    UnderGrad Grad Faculty Secretary

    Generalization

    SpecializationIs-A Is-A Is-A Is-A

    Is-A Is-A

    I h it

  • 7/31/2019 Semantic Data Modeling

    28/30

    Semantic Modeling 28CIS

    Inheritance

    oA supertype contains the common properties of all its subtypeentities.

    oSubtype inherits properties of its supertype and may have its

    own properties.

    PersonPerson

    EmployeeEmployee DependentDependent

    Project

    Member

    Project

    Member

    Project

    Manager

    Project

    Manager

    ID, Name, Address

    Birth-dateSalary, Skill

    Is-A Is-A

    Is-A Is-A

    Ratio-of-success, ... Languages, ...

    ER E l I l i

  • 7/31/2019 Semantic Data Modeling

    29/30

    Semantic Modeling 29CIS

    ER Example In-class exercise

    A database is being constructed to keep track of the teams and games of abaseball league. A team has a number of players, not all of whom participate in

    each game. It is desired to keep track of the players participating in each gamefor each team, the positions they played in that game, and the result of thegame. Design an ER schema diagram for this application

    Assumptions:Each game in the schedule is identified by a unique Game#, and a game is alsoidentified uniquely by the combination of Date, starting Time, and Field where itis played. A performance attribute is used to store information on the individual

    batting performance of each player in a game.

    EER Modeling Example

  • 7/31/2019 Semantic Data Modeling

    30/30

    Semantic Modeling 30CIS

    EER Modeling Example

    American Airlines CompanyThe American Airlines Company publishes a monthly flight log report that tracks

    which type of aircraft and the number of hours that were flown by anindividual pilot. A separate report is prepared for each pilot and is used to

    monitor pilot flight proficiency for the two types of aircraft (fixed-wing androtorcraft) which a pilot may be qualified to fly.

    The following business rules apply to this report. Pilots may be assigned to flydifferent aircraft each day by the flight scheduling manager. Each aircrafthas a single crew chief permanently assigned to perform maintenance on the

    aircraft, although a crew chief may crew more than one aircraft. Eachaircraft is identified by an aircraft number. There are several aircraft types inthe fleet. An aircraft number is unique within an aircraft type.

    Identify the entities in this situation and draw an E-R diagram of the entities toinclude their relationships and any attributes identified in this example. Give

    examples of additional attributes that might be associated with each entity.