Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (225.9 KB, 35 trang )
<span class='text_page_counter'>(1)</span><div class='page_container' data-page=1>
300 200 400 300 400 200
S1 Smith 20 London S3 Blake 30 Paris
S2 Jones 10 Paris
300
400 300 400 200
200
S1 Smith 20 London
S3 Blake 30 Paris
S2 Jones 10 Paris
P1 Nut Red 12 London P2 Bolt Green 17 Paris
P3 Screw Blue 17 Rome
P4 Screw Red 14 London
S2 Jones 10 Paris 400
S2 Jones 10 Paris 300
S3 Blake 30 Paris 200
S1 Smith 20 London 300
S1 Smith 20 London 200
P1 Nut Red 12 London P2 Bolt Green 17 Paris
P3 Screw Blue 17 Rome
P4 Screw Red 14 London
S2 Jones 10 Paris 300 <sub> S3 Blake 30 Paris 200</sub>
S1 Smith 20 London 300
S1 Smith 20 London 400
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).
All entities in an entity set have the same set of
attributes. (Until we consider ISA hierarchies,
anyway!)
Each entity set has a key.
<b>Employees</b>
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
Have an Id, Name, Login, Age, Gpa
Have an Id, Name, Credit Hours
<b>Students</b>
<b>Name</b> <b>Login</b>
<b>Id</b>
<b>Age</b>
<b>Gpa</b>
<b>Courses</b>
<b>Id</b> <b>Name</b> <b>Credit</b>
Name, Address, Phone #, Age
Name, Manufacturer , Expiration Date
<b>Patients</b>
<b>Name</b> <b>Addr</b> <b>Phone</b>
<b>Age</b>
<b>Drug</b>
<b>Name</b> <b>Manuf</b> <b>Exp</b>
Mọi phòng ban đều có trưởng phịng?
Nếu đúng, đây là ràng buộc 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
Have an Id, Name, Login, Age, Gpa
Have an Id, Name, Credit Hours
<b>Students</b>
<b>Name</b> <b>Login</b>
<b>Id</b>
<b>Age</b>
<b>Gpa</b>
<b>Courses</b>
<b>Id</b> <b>Name</b> <b>Credit</b>
<b>Enrolled_In</b>
Một thực thể yếu (weak entity) có thể được nhận biết
khi xét khóa chính của thực thể chủ nhân khác.
Tập thực thể chủ nhân và tập thực thể yếu cùng tham gia vào
1 mối kết hợp 1-nhiêu (1 chủ nhân, nhiều thực thể yếu).
Tập thực thể yếu phải tham gia đầy đủ vào tập kết hợp
identifying relationship set.
<b>lot</b>
<b>name</b>
<b>age</b>
<b>pname</b>
<b>ssn</b> <b>cost</b>
<b>Contract_Emps</b>
<b>name</b>
<b>ssn</b>
<b>Employees</b>
<b>lot</b>
<b>hourly_wages</b>
<b>ISA</b>
<b>Hourly_Emps</b>
<b>contractid</b>
<b>hours_worked</b>
Được dùng khi một
mối kết hợp bao
hàm nhiều thực thể
hoặc mối kết hợp
khác.
Aggregation allows
us to treat a
relationship set as an
entity set for
purposes of
participation in
(other) relationships.
Monitors mapped to
table like any other
<i> Mối kết hợp Tam phân và Aggregation</i>:
Monitors is a distinct relationship,
with a descriptive attribute.
Thiết kế lược đồ ER theo thông tin sau:
Walmart Stores
Store Id, Address, Phone #
Products
Product Id, Description, Price
Manufacturers
Name, Address, Phone #
Walmart Stores carry products
Amount in store
Manufacturers make products
Liệu <b>address</b> là thuộc tính của Employees hay là
một thực thể (nối với Employees bằng một quan hệ)?
Phụ thuộc vào ngữ nghĩa và cấu trúc của dữ liệu
<b>address:</b>
Nếu mỗi nhân viên có nhiều địa chỉ thì <b>address</b> phải là một
thực thể (vì thuộc tính khơng thể là một tập giá trị).
Nếu địa chỉ là một dữ liệu có cấu trúc (city, street, etc.) và
Works_In2 does not
allow an employee to
work in a department
for two or more
periods.
Similar to the problem
of wanting to record
several addresses for
an employee: we want
to record several
values of the
manager gets a separate
discretionary budget for
Redundancy of dbudget,
which is stored for each
dept managed by the
manager.
Misleading: suggests
dbudget tied to managed
dept.
What if a manager gets a
discretionary budget that
covers all managed
Key constraint
on Policies
S “can-supply” P, D “needs” P, and D “deals-with”
S does not imply that D has agreed to buy P from
S.
Thiết kế mức khái niệm phù hợp với phân tích yêu
cầu.
Yields a high-level description of data to be stored
Mô hình ER
Constructs are expressive, close to the way people think
about their applications.
Basic constructs: entities, relationships, and
attributes (of entities and relationships).
Some additional constructs: weak entities, ISA
Some constraints (notably, functional
dependencies) cannot be expressed in the ER
ER design is subjective. There are often many ways
to model a given scenario! Analyzing alternatives can
be tricky, especially for a large enterprise. Common
choices include:
Entity vs. attribute, entity vs. relationship, binary or n-ary
relationship, whether or not to use ISA hierarchies, and
whether or not to use aggregation.
Ensuring good database design: resulting relational
schema should be analyzed and refined further. FD
information and normalization techniques are