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

提交评论