Date: 12 March

Tutorial and Assignment
[20200309~20200317] Tutorial No.4 - 22 MAR

Design Phases

Outline of ER Model

Entity Sets

L06 Database Design Using the E-R Model - 图1

Composite Attributes

address

  • street
    • street name
    • street number
  • city
  • state
  • postal_code

Expressing Weak Entity Sets

L06 Database Design Using the E-R Model - 图2Advisor is a set of connected with section and course

E-R Diagram for a University Enterprise

L06 Database Design Using the E-R Model - 图3 L06 Database Design Using the E-R Model - 图4 many-to-many relationship
An instructor may advise many students, and a student may have many advisors

Redundant Attributes

L06 Database Design Using the E-R Model - 图5 Just one for more
schema for relationship set advisor

  1. advisor = (s_id, i_id)

Loop

Prereq is many to many

L06 Database Design Using the E-R Model - 图6

Weak entity set

L06 Database Design Using the E-R Model - 图7 (phone_number) is multivalued attribute M

冗余(Redundancy):存储两次数据,以便使系统更快速。 主键(Primary Key):主键是唯一的。同一张表中不允许出现同样两个键值。一个键值只对应着一行。 外键(Foreign Key):用于连接两张表。


Redundancy 冗余 of Schemas

  1. classroom (building, room_number, capacity)
  2. >> classroom (building, room_number, capacity)
  3. course (course_id, title, credits)
  4. >> course (course_id, title, dept_name, credits)
  5. department (dept_name, building, budget)
  6. >> department (dept_name, building, budget)
  7. instructor (ID, name, salary)
  8. >> instructor (ID, name, dept_name, salary)
  9. student (ID, name, tot_cred)
  10. >> student (ID, name, dept_name, tot_cred)
  11. section (course_id, sec_id, semester, year)
  12. >> section (course_id, sec_id, semester, year, building, room, time_slot_id)
  13. time slot (time_slot_id, day, start_time, end_time)
  14. >> time slot (time_slot_id, day, start_time, end_time)
  15. teaches (ID, *course_id, sec_id*, semester, year)
  16. >> teaches (ID, course_id, sec_id, semester, year)
  17. takes (

Specialization

Attribute inheritance
Overlapping
Disjoint

Completeness constraint

total
an entity must belong to one of the lower-level entity sets

partial
an entity need not belong to one of the lower-level entity sets

Aggregation

image.png

Same information will take overlapping
image.png

schema eval_for is

  1. class eval_for {
  2. ..
  3. S_ID,
  4. project_id,
  5. i_ID,
  6. evaluation_id
  7. }
  8. create table eval_for {
  9. S_ID,
  10. project_id,
  11. i_ID,
  12. evaluation_id
  13. }

Design Issues

Common Mistakes in E-R Diagrams

image.png
dept_name is emlinate

image.png
show the diagram
assignment or marks can only make one inside stud_section schema.

Correct form
image.png

Assignment Mark
01 10
02 12

Entities vs Attributes

L06 Database Design Using the E-R Model - 图13Phone number is not a nessary component in instructor so it is enough to set inside instructor as Attributes rather than entitles sets.

To simply the structure

image.png

Alternative ER Notations

L06 Database Design Using the E-R Model - 图15