【正文】
值,某些屬性值之間應(yīng)滿足一定的函數(shù)關(guān)系,某個(gè)屬性的取值范圍等等。 end。 street : string。如果 F與基本關(guān)系 S的主碼 KS相對(duì)應(yīng),則稱 F是基本關(guān)系 R的外碼 (foreign Key). – S(sno,name,age,sex,deptno), D(deptno,deptname) – S(sno,name,age), C(o,ame), SC(sno,o,grade) ? 外碼或者取空值,或者取參照關(guān)系中的主碼值 47 ?2022 Xiaojie Yuan 用戶定義完整性 (Userdefined Integrity) ? 用戶定義的完整性就是針對(duì)某一具體關(guān)系數(shù)據(jù)庫(kù)的約束條件。 entities have null in attributes that don’t belong to them. 29 ?2022 Xiaojie Yuan Example Beers Ales isa name manf color 30 ?2022 Xiaojie Yuan Object Oriented name manf Bud AnheuserBusch Beers name manf color Summerbrew Pete’s dark Ales Beers Ales isa name manf color 31 ?2022 Xiaojie Yuan E/R Style name manf Bud AnheuserBusch Summerbrew Pete’s Beers name color Summerbrew dark Ales Beers Ales isa name manf color 32 ?2022 Xiaojie Yuan Using Nulls name manf color Bud AnheuserBusch NULL Summerbrew Pete’s dark Beers Beers Ales isa name manf color 33 ?2022 Xiaojie Yuan Comparisons ? OO approach good for queries like “find the color of ales made by Pete’s.” – Just look in Ales relation. ? E/R approach good for queries like “find all beers (including ales) made by Pete’s.” – Just look in Beers relation. ? Using nulls saves space unless there are lots of attributes that are usually null. 34 ?2022 Xiaojie Yuan 數(shù)據(jù)模型三要素 ? 數(shù)據(jù)結(jié)構(gòu) –所研究的對(duì)象類型的集合。1 ?2022 Xiaojie Yuan The Relational Data Model ? Tables ? Schemas ? Conversion from E/R to Relations 2 ?2022 Xiaojie Yuan Database Modeling amp。 entity represented in all relations to whose subclass/. it belongs. 3. Use nulls : create one relation。 46 ?2022 Xiaojie Yuan 參照完整性 (Referential Integrity) ? 設(shè) F是基本關(guān)系 R的一個(gè)或一組屬性,但不是關(guān)系 R的碼。 48 ?2022 Xiaojie Yuan Levels of Abstraction ? Physical level describes how a record (., customer) is stored. ? Logical level: describes data stored in database, and the relationships among the data. type customer = record name : string。 ? View level: application programs hide details of data types. Views can also hide information (., salary) for security purposes. 49 ?2022 Xiaojie Yuan View of Data An architecture for a database system 50 ?2022 Xiaojie Yuan Translation Review ? Basic cases – entity to table, relation to table – selecting attributes based on keys ? Special cases – manyone relation can be merged – merging manymany is dangerous – translating weak entity sets – translating isa hierarchy ? 3 choices, with tradeoffs 51 ?2022 Xiaojie Yuan loan(loan_number, amount) payment(loan_number, payment_number, payment_date, payment_amount) customer(name, address) borrows(name, loan_number)