DatabaseDesign_第1頁
DatabaseDesign_第2頁
DatabaseDesign_第3頁
DatabaseDesign_第4頁
DatabaseDesign_第5頁
已閱讀5頁,還剩27頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論