DatabaseDesign_第1頁(yè)
DatabaseDesign_第2頁(yè)
DatabaseDesign_第3頁(yè)
DatabaseDesign_第4頁(yè)
DatabaseDesign_第5頁(yè)
已閱讀5頁(yè),還剩27頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、Database DesignApril 3, 20021Projects, More DetailsGoal: build a DB application.(almost) anything goes.Groups of 3-4.End of week 2: groups formed.End of week 3: proposals, E/R diagramsEnd of week 5: project specs dueEnd of week 7: sample end-to-end app dueJune 7th: demos2Building an Application with

2、 a DBMSRequirements modeling (conceptual, pictures)Decide what entities should be part of the application and how they should be linked.Schema design and implementationDecide on a set of tables, attributes.Define the tables in the database system.Populate database (insert tuples).Write application p

3、rograms using the DBMSway easier now that the data management is taken care of.3OutlineODL - Object Definition Language (2.1)E/R - Entity relationship diagrams (2.2)Design Principles (2.3)4Database DesignWhy do we need it? Agree on structure of the database before deciding on a particular implementa

4、tion.Consider issues such as:What entities to modelHow entities are relatedWhat constraints exist in the domainHow to achieve good designs5Database Design Formalisms1. Object Definition Language (ODL): Closer in spirit to object-oriented models2. Entity/Relationship model (E/R):More relational in na

5、ture.Both can be translated (semi-automatically) to relational schemas ODL to OO-schema: direct transformation (C+ or Smalltalk based system).61. Object Definition LanguageODL is part of ODMGsuperset of Corbas IDL Resembles C+ (and Smalltalk).7ODL PrinciplesBasic design paradigm in ODL: Model object

6、s and their properties.For abstraction purposes:Group objects into classes.What qualifies as a good class?Objects should have common properties.8ODL Class DeclarationsClass declaration:Methods: arbitrary function, of little concern for us hereInterface attributes: ; relationships ; methods (param)9O

7、DL ExampleProductPersonCompanycategorynamepricenamestockpricenameaddressssn10ODL DeclarationsInterface Product attribute string name; attribute float price; attribute enum Categories electronics, communications, sports category Interface Company attribute string name; attribute float stockprice; Int

8、erface Person attribute integer ssn; attribute string name; attribute struct Address string street, string city address; So far just simplified C+ with slightly different syntax11ODL Example ExtendedProductPersonCompanycategorynamepricenamestockpricenameaddressssnbuysworksFormadeBy12ODL Declarations

9、, ExtendedInterface Product attribute string name; attribute float price; attribute enum Categories electronics, communications, sports category; relationship madeBy; Interface Person attribute integer ssn; attribute string name; attribute Struct Address string street, string city address; relations

10、hip set buys; relationship set worksFor;relationship corresponds somewhat to pointers in C+13ODL Example, Extended AgainProductPersonCompanycategorynamepricenamestockpricenameaddressssnbuysworksFormadeByemploysmakes14ODL Declarations, Extended AgainInterface Company attribute string name; attribute

11、float stockprice; relationship set makes inverse Product:madeBy; relationship set employs inverse Person:worksFor; 15Types in ODLBasic types: Atomic types (e.g., string, integer, ) Interface types (e.g., Person, Product, Company)Constructors:collection types: Set: 1, 5, 6 Bag: 1, 1, 5, 6, 6 List: 1,

12、 5, 6, 1, 6 Array: integer17structured types: Struct string street, string city, integer zipcode16Collection TypesSets:order, number of occurrences dont matter4,7,9 = 7,9,7,4 = 9,4,7Bags:number of occurrences matter, order not:7,9,7,4=7,7,9,4, is different from 4,7,9Lists:order, number of occurrence

13、s matter:4,7,9 different from 9,4,717Allowable Types in ODLFor attributes: atomic/struct, or collection of atomic/struct OK: string, set Not OK: Product, setsetFor relationships: interface, or collection of interface. OK: Product, set, list Not OK: struct pname Product, cname Company setbag integer1

14、82. Entity / Relationship DiagramsObjects entitiesClasses entity setsAttributes are like in ODL.Relationships: like in ODL except - first class citizens (not associated with classes) - not necessarily binaryProductaddressbuys19addressnamessnPersonbuysmakesemploysCompanyProductnamecategorystockpricen

15、ameprice20What is a Relation ?A mathematical definition:if A, B are sets, then a relation R is a subset of A x BA=1,2,3, B=a,b,c,d, R = (1,a), (1,c), (3,b)- makes is a subset of Product x Company:123abcdA=B=makesCompanyProduct21Multiplicity of E/R Relationsone-one:many-onemany-many123abcd123abcd123a

16、bcd22Multi-way RelationshipsHow do we model a purchase relationship between buyers,products and stores?PurchaseProductPersonStoreCan still model as a mathematical set (how ?)23Q: what does the arrow mean ?A: if I know the store, person, invoice, I know the movie tooRentalVideoStorePersonMovieInvoice

17、Arrows in Multiway Relationships24Q: what do these arrow mean ?A: store, person, invoice determines movie and store, invoice, movie determines personRentalVideoStorePersonMovieInvoiceArrows in Multiway Relationships25Q: how do I say: “invoice determines store” ?A: no good way; best approximation:Q:

18、Why is this incomplete ?RentalVideoStorePersonMovieInvoiceArrows in Multiway Relationships26Roles in RelationshipsPurchaseWhat if we need an entity set twice in one relationship?ProductPersonStoresalespersonbuyer27Attributes on RelationshipsPurchaseProductPersonStoredate28Converting Multi-way Relationships to BinaryPurchasePersonStoreProductStoreOfProductOfBuyerOfdate293. Design PrinciplesPurchaseProductPerso

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論