COSC 2307: Database Programming - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

COSC 2307: Database Programming

Description:

A key attribute may be composite. ... One customer can have zero to many of the order entity. employee. spouse. employee. project ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 12
Provided by: publicpc8
Category:

less

Transcript and Presenter's Notes

Title: COSC 2307: Database Programming


1
COSC 2307 Database Programming
  • Lecture 3 Entity Relationship (ER) Model
  • Julia Johnson
  • Fall 2008
  • (www.cs.laurentian.ca/julia/courses/cosc2307/
  • index.html )

2
This lecture
  • Entities and Attributes
  • Relationships
  • Entity Relationship Diagram (ERD)
  • Constraints on Relationships

3
Entities and Attributes
  • Entities are specific objects or things in the
    mini-world that are represented in the database
    for example EMPLOYEE, DEPARTMENT, PROJECT.
  •  
  • Attributes are properties used to describe an
    entity for example an EMPLOYEE entity may have a
    Name, SSN, Address, Sex, BirthDate.
  •  
  • A specific entity will have a value for each of
    its attributes for example a specific EMPLOYEE
    entity may have Name'John Smith',
    SSN'123456789', Address'731 Fondren, Houston,
    TX', Sex'M', BirthDate'09-JAN-55'.

4
Types of Attributes
  • Simple Each entity has a single atomic value
    for the attribute for example SSN or Sex.
  •  
  • Composite The attribute may be composed of
    several components for example Address(Apt,
    House, Street, City, State, ZipCode, Country) or
    Name(FirstName, MiddleName, LastName).
  • Composition may form a hierarchy where some
    components are themselves composite.
  • Single-Valued an attribute with a single value
    e.g. Age
  • Multi-valued An attribute may have multiple
    values for the same entity for example Color of
    a CAR or PreviousDegrees of a STUDENT. Denoted as
    Color or PreviousDegrees.

5
Key Attributes
  • An attribute of an entity type for which each
    entity must have a unique value is called a key
    attribute of the entity type. For example SSN of
    EMPLOYEE.
  • A key attribute may be composite. For example,
    vehicle Registration Number is a key of the CAR
    entity type with components (Number, State).
  •  
  • An entity type may have more than one key. For
    example, the CAR entity type may have two keys
    VehicleIdentificationNumber and
    VehicleRegistrationNumber(Number, State).

6
Relationships
  • A relationship relates two or more distinct
    entities with a specific meaning
  • For example, EMPLOYEE John Smith works on the
    ProductX PROJECT or EMPLOYEE Franklin Wong
    manages the Research DEPARTMENT.
  • The degree of a relationship - number of
    participating entity types.
  • Both MANAGES and WORKS_ON are binary
    relationships.

7
Entity Relationship diagram (ERD)
Employee
Works_on
Project
Employee
Manages
Department
8
Constraints on Relationships
  • Structural constraints on relationships
  • Cardinality ratio (of a binary relationship)
    11, 1N, and MN
  • Participation constraint (on each participating
    entity type) total (called existence dependency
    ) or partial.
  • EMPLOYEE in WORKS_ON relationship is a total
    participation
  • EMPLOYEE in the MANAGES relationship type is
    partial
  • recursive relationship A relationship that
    relates two entities of the same entity type.
  • For example, a SUPERVISION relationship type
    relates one EMPLOYEE (in the role of supervisee )
    to another EMPLOYEE (in the role of supervisor ).

9
Cardinality
  • One-to-one (11) relationship
  • One-to-many (1M) relationship
  • Many-to-many (MN) relationship

1
1
Chair of
Faculty member
Department
M
1
student
Faculty advisor
advises
M
N
Enrolls in
student
class
10
Crow Foot Notation for ERD
order
customer
places
One customer can have zero to many of the order
entity
client
has
address
One client can have one address or many
employee
spouse
has
One employee can have one spouse or none
Assigned to
project
employee
Zero to many employees can be
assigned to zero to many projects
11
Northwoods University Student Registration
Database
  • Starts on p23 of your text

12
Sample Database from Assignment 1
Write a Comment
User Comments (0)
About PowerShow.com