Professional Documents
Culture Documents
Database MEF 2021 BC 2
Database MEF 2021 BC 2
Pick application
Conceptual design
domain
What data do I
need for my
application
How can I domain?
describe that
data?
2
STEPS IN BUILDING A DB APPLICATION
Pick application
Conceptual design
domain
diagram
SQL & Java/C+
ER
+/etc + user
interface
Entity-relationship (ER) data model allows us to describe the data involved in a real-world
enterprise in terms of objects and their relationships and is widely used to develop an initial
database design.
4
DATABASE DESIGN STEPS
• (1) Requirements Analysis: What data to store, what the users want from the
database
• (2) Conceptual Database Design: high level description of the data (ER Model)
5
BEYOND THE ER MODEL
• A more careful analysis can often refine the logical schema obtained at the end
of Step 3. Once we have a good logical schema, we must consider performance
criteria and design the physical schema.
6
DATABASE DESIGN STEPS (CONTINUED)
• (6) Security Design:we identify different user groups and different roles played by
various users
7
ENTITY RELATIONSHIP (E/R) MODEL
• A popular data model – useful to database designers
– Graphical representation of miniworld
8
E/R MODEL: ENTITIES AND ENTITY SETS
9
E/R MODEL: ATTRIBUTES
(NITELIKLER) ID Name
• Attributes are:
– Properties of entities Student
• Like fields in a struct
• Like columns in a table/spreadsheet
• Like data members in an object
– Values in some domain (e.g., ints, strings)
• Attributes are simple values, e.g. integers or character strings, not structs, sets, etc.
• Represented by ovals:
10
RELATIONSHIPS
11
E/R MODEL: RELATIONSHIPS
• Students Enroll in courses
• Courses are Held in rooms
• The E/R data model:
Students Enroll Courses
ID Name Held
Semester
Rooms
12
A LITTLE SET THEORY
• A mathematical set is a collection of members
• A set is defined by its members
– No other structure, no order, no duplicates allowed
• Sets specified by listing:
– {1, 2, 3, …} = S
• Or by “set-builder” notation:
– { x in S: 2 divides x} = ?
– { x in Presidents | reelected(x)} = ?
A 2 b
A = {1, 2, 3} B = {a, b, c, d}
c
3
R = {(1,a), (1,c), (3,b)} B d
• No arrow: many-to-many
• Sharp arrow: many-to-one
• Rounded arrow: “exactly one”
– “key constraint”
• One-one:
16
REPRESENTING “MULTIPLICITY”
• Show a many-one relationship by an arrow
entering the “one” side.
18
EXAMPLE E/R DIAGRAM
Name
Name
ID ID
Assisting
ID TA Name
19
EXAMPLE E/R DIAGRAM
20
MULTIWAY RELATIONSHIPS Courses
Students Enrolls
Enrolls entries:
Students Courses TAs TAs
21
SECOND MULTIWAY E.G.: RENTING MOVIES
• Scenario: a Customer Rents a Movie from a VideoStore
on a certain date
date
VideoStore
Rental Movie
Customer
23
KEYS
• A key is a set of attributes for one entity set such that no two entities in this set agree on all the
attributes of the key.
– It is allowed for two entities to agree on some, but not all, of the key attributes.
• We must designate a key for every entity set.
24
UNDERLINE THE KEY FOR EACH ENTITY SET
name category
multi-attribute keys
price are okay!
Product
Multiple
“candidate keys”?
Pick just one to be Is this a good
the key. Person
key?
25
EXAMPLE: A MULTI-ATTRIBUTE KEY
Courses
26
END OF LECTURE 2
N E X T W E E K : E R D I A G R A M S PA RT 2
27