DOC PREVIEW
UW CSE 444 - Lecture Notes

This preview shows page 1-2-14-15-30-31 out of 31 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 31 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 31 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 31 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 31 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 31 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 31 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 31 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Arrows in Multiway RelationshipsSlide 2Slide 3Lecture 3: Database Modeling (continued)OutlineModeling SubclassesSubclasses in ODLUnderstanding SubclassesSubclasses for Heterogeneous CollectionsMultiple Inheritance in ODLSlide 11Understanding Multiple InheritanceHow do we resolve conflicts?Difference between ODL and E/R inheritanceSlide 16Slide 17Modeling UnionTypes With SubclassesModeling Union Types with SubclassesSlide 20ConstraintsModeling ConstraintsKeysKeys in ODLKeys in E/R DiagramsSingle Value ConstraintsSlide 27Slide 28Referential Integrity ConstraintsSlide 30Weak Entity Sets•Q: what does the arrow mean ?•A: if I know the store, person, invoice, I know the movie tooRentalVideoStorePersonMovieInvoiceArrows in Multiway Relationships•Q: what do these arrow mean ?•A: store, person, invoice determines movie and store, invoice, movie determines personRentalVideoStorePersonMovieInvoiceArrows in Multiway Relationships•Q: how do I say: “invoice determines store” ?•A: no good way; best approximation:•Why is this incomplete ?RentalVideoStorePersonMovieInvoiceArrows in Multiway RelationshipsLecture 3: Database Modeling (continued)Sept. 29, 2000Outline•Subclasses (2.4)•Constraints: (2.5)•Weak entity sets (2.6)Modeling SubclassesSome objects in a class may be special•define a new class•better: define a s ubclass ProductsSoftware productsEducational productsSo --- we define subclasses (in ODL and in E/R).Subclasses in ODLinterface SoftwareProduct: Product{ attribute string platform; attribute integer requiredMemory;}interface EducationalProduct: Product{ attribute struct Interval {integer begin, integer end} ageGroup; attribute string topic;}The two classes i nherit all the properties of Product.Understanding Subclasses•Think in terms of records:–Product–SoftwareProduct–EducationalProductfield1field2field1field2field1field2field3field4field5Subclasses for Heterogeneous CollectionsNow consider a class referring to Product:interface Vendor { attribute string name; relationshiop Set<Product> offers;}Some offers are Product, others are SoftwareProduct, or EducationalProductMultiple Inheritance in ODL ProductEducational ProductEduc-softwareProductSoftware ProductageGrouptopicPlatformsrequired memoryEducational-methodinterface EducSoftwareProduct: SoftwareProduct, EducationalProduct { attribute string educational-method;}Understanding Multiple Inheritance•Think in terms of records:–EducSoftwareProductfield1field2field3field4field5How do we resolve conflicts? ProductEducational ProductEduc-softwareProductSoftware ProductageGrouptopicPlatformsrequired memoryEducational-methodRating(ATA)Rating(ASA)Rating?Productname categorypriceisa isaEducational ProductSoftware ProductAge GroupplatformsSubclasses in E/R Diagrams•ODL: classes are disjointp1p2p3sp1sp2ep1ep2ep3Difference between ODL and E/R inheritanceProductSoftwareProductEducationalProduct•E/R: entity sets overlapDifference between ODL and E/R inheritanceSoftwareProductEducationalProductp1p2p3sp1sp2ep1ep2ep3Product•No need for multiple inheritance in E/R•we have three entity sets, but four different kinds of objectsSoftwareProductEducationalProductp1p2p3sp1sp2ep1ep2ep3Productesp1esp2Modeling UnionTypes With SubclassesFurniturePiecePersonCompanySay: each piece of furniture is owned either by a person, or by a companyModeling Union Types with SubclassesSay: each piece of furniture is owned either by a person, or by a companySolution 1. Acceptable, imperfect (What’s wrong ?)FurniturePiecePersonCompanyownedByPerson ownedByPersonModeling Union Types with SubclassesSolution 2: better, more laboriousisaFurniturePiecePersonCompanyownedByOwnerisaConstraints•A constraint = an assertion about the database that must be true at all times•part of the db schema•types in programming languages do not have anything similar•correspond to invariants in programming languagesModeling ConstraintsFinding constraints is part of the modeling process. Commonly used constraints: Keys: social security number uniquely identifies a person. Single-value constraints: a person can have only one father. Referential integrity constraints: if you work for a company, it must exist in the database. Domain constraints: peoples’ ages are between 0 and 150. General constraints: all others (at most 50 students enroll in a class)KeysA set of attributes that uniquely identify an object or entity: Person: social security number name name + address name + address + agePerfect keys are often hard to find, so organizations usuallyinvent something. An object may have multiple keys: employee number, social-security numberKeys in ODLInterface Person (key ssn) { attribute string ssn; attribute string name; ... }Defining multiple keys: (key ssn employeID (name address age))Keys in E/R Diagramsaddressname ssnPersonProductname categorypriceNo formal way to specify multiple keys in E/R diagramsSingle Value Constraints•Sometimes we can choose to allow one or more values•ODL: –attributes are always single value–relationships have single or multiple valuesrelationship person president;relationship set<person> presidents;Single Value Constraints•E/R:offers offersSingle Value ConstraintsSingle Value Constraint: •we explicitly require one value•two flavors:–allow nulls–do not allow nullsReferential Integrity Constraints•In some formalisms we may refer to other object but get garbage instead–e.g. a dangling pointer in C/C++•the Referential Integrity Constraint explicitly requires a reference to existsReferential Integrity Constraints•In ODL:– means that a relationship cannot be NULL•In E/R:CompanyProductmakesCompanyProductmakesWeak Entity SetsEntity sets are weak when their key attributes come from otherclasses to which they are related.This happens if: - part-of hierarchies - splitting n-ary relations to binary.UniversityTeamaffiliationnumbersport


View Full Document

UW CSE 444 - Lecture Notes

Documents in this Course
XML

XML

48 pages

SQL

SQL

25 pages

SQL

SQL

42 pages

Recovery

Recovery

30 pages

SQL

SQL

36 pages

Indexes

Indexes

35 pages

Security

Security

36 pages

Wrap-up

Wrap-up

6 pages

SQL

SQL

37 pages

More SQL

More SQL

48 pages

SQL

SQL

35 pages

XML

XML

46 pages

Triggers

Triggers

26 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?