Data Modeling
Data Modeling
Business rules
Business rule is a statement that defines or
A
constraints some aspects of the business.
are derived from policies, procedures, events, functions,
and other business objects, and state constraints on the
organization.
govern how data are handled and stored.
govern creating, updating, and removing data in an
information processing and storage system.
Examples
Business rules
Business rules
Entity-Relationship Model
Entity
symbols
Relationship
symbols
A special
entity that is
also a
relationship
Attribute
symbols
10
Entities
11
SHOULD BE:
An object that will have many instances in the
database
An object that will be composed of multiple
attributes
An object that we are trying to model
SHOULD NOT BE:
A user of the database system
An output of the database system (e.g. a report)
12
Inappropriate entities
Systemuser
Systemoutput
Appropriate entities
13
Entities
Exercise
Identify possible entities in the following description.
An Airline company wants to store and manage their
data on flights. They own several airplanes, each
with a certain number of seats, and have a number
of employees. Also they have customers in their
frequent flyer program, each has a certain mileage in
his/her account. The planes are assigned to certain
flights, as well as employees, and customers can buy
seats on the flights. Each flight has a destination, a
time and date, and a number of miles.
14
Attributes
15
Identifiers (Keys)
16
Characteristics of identifiers
17
A composite attribute
Anattribute
brokeninto
componentparts
18
Thekeyisunderlined
19
Thekeyiscomposed
oftwosubparts
20
Multivalued:
an employee can have
more than one skill
21
22
Attributes
Exercise
Identify possible attributes in the example from last
exercise. Find additional possible attributes. Decide
on which attributes would be multi-valued, and which
would be candidate keys.
An Airline company wants to store and manage their
data on flights. They own several airplanes, each
with a certain number of seats, and have a number
of employees. Also they have customers in their
frequent flyer program, each has a certain mileage in
his/her account. The planes are assigned to certain
flights, as well as employees, and customers can buy
seats on the flights. Each flight has a destination, a
time and date, and a number of miles.
Engineering and Technology Management
23
Relationships
24
Degree of relationships
25
Degree of relationships
One entity
related to
another of
the same
entity type
Entities of two
different
types related
to each other
Entities of
three
different
types related
to each other
26
Unary relationships
27
Binary relationships
28
Ternary relationships
29
Cardinality of relationships
One to One
Each entity in the relationship will have exactly one
related entity
One to Many
An entity on one side of the relationship can have
many related entities, but an entity on the other side
will have a maximum of one related entity
Many to Many
Entities on both sides of the relationship can have
many related entities on the other side
30
Cardinality constraints
31
Cardinality
32
33
34
Relationship type
35
Here,thedatecompletedattributepertainsspecifically
totheemployeescompletionofacourseitisan
attributeoftherelationship.
36
37
Representingabillofmaterialsstructure
Engineering and Technology Management
38
39
Here,max
cardinality
constraint is 4
40
Cardinalities
Exercise
Find the right cardinalities...
Id
Name
Student
Grade
takes
advises
Professor
Engineering and Technology Management
Course
uses
Textbook
41
Cardinalities
Exercise
Infer the business rule difference(s) to Bogazici.
Professor
Course
gives
Customer
Date
Customer
Product
buys
Invoice
Product
buys
Invoice
42
Strong entities
exist independently of other types of entities
has its own unique identifier
represented with single-line rectangle
Weak entity
dependent on a strong entitycannot exist on its own
does not have a unique identifier
represented with double-line rectangle
Identifying relationship
links strong entities to weak entities
represented with double line diamond
43
Strong entity
Identifying
relationship
Weak entity
44
Supertype / Subtype
Implements generalisation
All attributes of Supertype pertain to Subtypes
Normally split on one attribute
Subset
Similar, but non-excluse
One entity instance can belong to more than one class
45
Supertype/subtyperelationships
46
ERD
Exercise
Model the following situation using ERD. Include
appropriate attributes.
A consulting company maintains offices in several
countries. Each office can have several employees
assigned, each employee is assigned to one office.
Customers offer projects to the company, each
project is from one customer. Employees work on the
project for a given time and intensity, and can work
on more than one project at the same time. A project
will have several employees assigned. Each
employee has a list of skills. An employee can be
either a senior or junior consultant (who has a date
for promotion set), a senior one manages several
junior one, each junior is assigned to one senior. For
each project, there can be several invoices with
different amounts and dates.
Engineering and Technology Management
47