Semantic Integrity Constraints
,Robert
的上司是 James
(888665555
) ,但 Robert
的薪水(58000
)比上司(55000
)還高。Bellaire
的 Dnum
應該是 5
而不是 2
。Dnumber
(Key
) 的 4
發生了重複。Pno
(Key
) 不可為 NULL
。18
歲。DEPARTMENT
、 WORKS_ON
、 DEPENEDENT
有 ssn
為 987654321
的資料在 reference ,不可刪除。WORKS_ON
有 Pno
為 1
(ProductX
) 的資料在 reference ,不可刪除。research
這個部門的經理變成 John
(123456789
),然而 John
的上司依舊是 Franklin
(333445555
),那這時候 Franklin
會屬於哪個部門? 應該不能這樣修改。ssn
為 943775543
的人,因此不能修改。Consider the following relations for a database that keeps track of business trips of
salespersons in a sales office:
A trip can be charged to one or more accounts. Specify the foreign keys for this schema,
stating any assumptions you make.
TRIP
的 Ssn
會 reference 到 SALESPERSON
的 Ssn
EXPENSE
的 Trip_id
會 reference 到 TRIP
的 Trip_id
我不知道 EXPENSE
的 Account#
代表意義是什麼,我唯一能想到的是類似台灣的統編,但又感覺不太對。
Consider the following relations for a database that keeps track of automobile sales in a car dealership (OPTION refers to some optional equipment installed on an automobile):
First, specify the foreign keys for this schema, stating any assumptions you make.
Next, populate the relations with a few sample tuples, and then give an example of an insertion in the SALE and SALESPERSON relations that violates the referential integrity constraints and of another insertion that does not
OPTION
的 Serial_no
會 reference 到 CAR
的 Serial_no
SALE
的 Salespersion_id
會 reference 到 SALESPERSON
的 Salesperson_id
SALE
的 Serial_no
會 reference 到 CAR
的 Serial_no
如果 insert
一個 SALE
的 tuple
時輸入了不存在於 SALESPERSON
中的 Salesperson_id
,會違反 constraints
。
直接在 SALESPERSON
中新增一個 tuple
不會違反。
Consider a STUDENT relation in a UNIVERSITY database with the following attributes
Note that the cell phone may be from a different city and state (or province) from the local phone.
(以下忽略)
a. Identify the critical missing information from the Local_phone and Cell_phone attributes.
(Hint: How do you call someone who lives in a different state or province?)
(06)
)b. Would you store this additional information in the Local_phone and Cell_phone attributes or add new attributes to the schema for STUDENT?
Table
來表示不同區域對應的區碼為何c. Consider the Name attribute. What are the advantages and disadvantages of splitting this field from one attribute into three attributes
(first name, middle name, and last name)?
d. What general guideline world you recommend for deciding when to store information in a single attribute and when to split the information?
attribute
,如果不會就可以考慮 split
e. Suppose the student can have between 0 and 5 phones. Suggest two different designs that allow this type of information.
STUDENT_PHONE
的 table
記錄學生的電話資訊table
再新增一個 tuple
1112_courses
database