Conceptual Modelling, Lecture notes of Computer Science

Database system development stages Stage 1 Requirements - Determine what database is required to do (both current and future needs) - Develop data model Stage 2 Design - Tables - Relationships - Indexes - Other structures Stage 3 Implement - Create database - Create tables and relationships - Create other structures - Input data - Test database

Typology: Lecture notes

2017/2018

Uploaded on 11/07/2018

bopaki-tebalo
bopaki-tebalo 🇧🇼

3 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1/23/2015
1
Lecture 2
Conceptual Modelling
The Entity-Relationship Model
Ref: Ramakrishnan and Gehrke 2003
Review of last lecture
History of Data Management
File-Based Systems
Databases and DBMS vs File Systems
Why Study Databases
Data Model
Structure of a DBMS
Components of DBMS environment
Roles in the Database Environment
1/23/2015 2
University of Botswana. CSI262 Lecture
Notes 2014/2015
Database system development stages
Stage 1 Requirements
- Determine what database is required to do (both current and
future needs)
- Develop data model
Stage 2 Design
- Tables
- Relationships
- Indexes
- Other structures
Stage 3 Implement
- Create database
- Create tables and relationships
- Create other structures
- Input data
- Test database
1/23/2015 3
University of Botswana. CSI262 Lecture
Notes 2014/2015
Overview of Database Design
Conceptual design: (ER Model is used at this
stage.)
What are the entities and relationships in the
enterprise?
What information about these entities and
relationships should we store in the database?
What are the integrity constraints or business rules
that hold?
A database `schema’ in the ER Model can be
represented pictorially (ER diagrams).
Can map an ER diagram into a relational schema.
1/23/2015 University of Botswana. CSI262 Lecture
Notes 2014/2015 4
ER Model Basics
Entity: Real-world object distinguishable from
other objects. An entity is described (in DB) using
a set of attributes.
Entity Set: A collection of similar entities. e.g., all
employees.
All entities in an entity set have the same set of
attributes. (Until we consider ISA hierarchies,
anyway!)
Each entity set has a key.
Each attribute has a domain.
1/23/2015 University of Botswana. CSI262 Lecture
Notes 2014/2015 5
Student
SId FName Surname
ER Model Basics
1/23/2015 University of Botswana. CSI262 Lecture
Notes 2014/2015 6
Student
SId FName Surname
Course
CId CName Grade
Relationship: Association among two or more entities. e.g., John
is enrolled for CSI362.
Relationship Set: Collection of similar relationships.
- An n-ary relationship set R relates n entity sets E1 ... En;
each relationship in R involves entities e1 Є E1, ..., en Є En
- Same entity set could participate in different relationship
sets, or in different “roles” in same set.
Employee
supervisor subordinate
Enrolled_In
Reports_to
EName EId
pf3

Partial preview of the text

Download Conceptual Modelling and more Lecture notes Computer Science in PDF only on Docsity!

Lecture 2

Conceptual Modelling

The Entity-Relationship Model

Ref: Ramakrishnan and Gehrke 2003

Review of last lecture

• History of Data Management

• File-Based Systems

• Databases and DBMS vs File Systems

• Why Study Databases

• Data Model

• Structure of a DBMS

• Components of DBMS environment

• Roles in the Database Environment

1/23/2015 University of Botswana. CSI262 Lecture Notes 2014/2015 2

Database system development stages

Stage 1 Requirements

- Determine what database is required to do (both current and

future needs)

- Develop data model

Stage 2 Design

- Tables

- Relationships

- Indexes

- Other structures

Stage 3 Implement

- Create database

- Create tables and relationships

- Create other structures

- Input data

- Test database

1/23/2015 University of Botswana. CSI262 Lecture Notes 2014/2015 3

Overview of Database Design

• Conceptual design : (ER Model is used at this

stage.)

– What are the entities and relationships in the

enterprise?

– What information about these entities and

relationships should we store in the database?

– What are the integrity constraints or business rules

that hold?

– A database `schema’ in the ER Model can be

represented pictorially ( ER diagrams ).

– Can map an ER diagram into a relational schema.

1/23/2015 University of Botswana. CSI262 Lecture Notes 2014/2015 4

ER Model Basics

• Entity: Real-world object distinguishable from

other objects. An entity is described (in DB) using

a set of attributes.

• Entity Set : A collection of similar entities. e.g., all

employees.

– All entities in an entity set have the same set of

attributes. (Until we consider ISA hierarchies,

anyway!)

– Each entity set has a key.

– Each attribute has a domain.

1/23/2015 University of Botswana. CSI262 Lecture Notes 2014/2015 5

Student

SId FName Surname

ER Model Basics

1/23/2015 University of Botswana. CSI262 Lecture Notes 2014/2015 6 Student SId FName^ Surname Course CId CName Grade

• Relationship: Association among two or more entities. e.g., John

is enrolled for CSI362.

• Relationship Set : Collection of similar relationships.

- An n-ary relationship set R relates n entity sets E1 ... En;

each relationship in R involves entities e1 Є E1, ..., en Є En

- Same entity set could participate in different relationship

sets, or in different “roles” in same set.

Employee supervisor subordinate

Enrolled_In

Reports_to EName EId

Key Constraints

• Consider Enrolled_In : A student can enroll in

many courses; a course can have many

students.

• In contrast, each dept has at most one

manager, according to the key constraint on

Manages.

(^1) 1/23/2015-to- 1 1 - toUniversity of Botswana. CSI262 Lecture-many Notes 2014/2015 Many - to- 1 Many-to-Many 7

Participation Constraints

• Does every department have a manager?

– If so, this is a participation constraint : the

participation of Departments in Manages is said to

be total (vs. partial ).

• Every Did value in Departments table must

appear in a row of the Manages table (with a

non-null EId value!)

1/23/2015 (^) University of Botswana. CSI262 Lecture Notes 2014/2015 8 Employee EId EName^ Surname Department DId DName^ Budget

Manages

Since

Works_In

Since 1/23/2015 University of Botswana. CSI262 Lecture Notes 2014/2015 9 EId EName (^) Surname Dependant Cost^ DName^ Age

Employee Policy

• A weak entity can be identified uniquely only

by considering the primary key of another

( owner ) entity.

– Owner entity set and weak entity set must

participate in a one-to-many relationship set (one

owner, many weak entities).

– Weak entity set must have total participation in

this identifying relationship set.

Weak Entities ISA (`is a’) Hierarchies

• As in C++, or other PLs, attributes are inherited. If

we declare A ISA B, every A entity is also

considered to be a B entity.

– Overlap constraints : Can Joe be an Hourly_Emps as

well as a Contract_Emps entity? ( Allowed/disallowed )

– Covering constraints : Does every Employees entity

also have to be an Hourly_Emps or a Contract_Emps

entity? (Yes/no)

• Reasons for using ISA:

– To add descriptive attributes specific to a subclass.

– To identify entities that participate in a relationship.

1/23/2015 University of Botswana. CSI262 Lecture Notes 2014/2015 10

ISA (`is a’) Hierarchies

1/23/2015 University of Botswana. CSI262 Lecture Notes 2014/2015 11 EId EName (^) Surname Employee Hourly_wages HrsWorked ContractId Hourly_Emp ISA Contract_Emp

Aggregation

• Used when we have to model a relationship

involving (entity sets and) a relationship set.

– Aggregation allows us to treat a relationship set

as an entity set for purposes of participation in

(other) relationships.

* Aggregation vs. ternary relationship:

– Monitors is a distinct relationship, with a

descriptive attribute.

– Also, can say that each sponsorship is monitored

by at most one employee.

1/23/2015 University of Botswana. CSI262 Lecture Notes 2014/2015 12