Download presentation
Presentation is loading. Please wait.
1
1 Unified Modeling Language Classes Associations Aggregations
2
2 A Bit of Roadmap uWe started with modeling: E/R and relational. uWe then spent 5 weeks talking about various aspects of database programming: SQL, JDBC, relational algebra, etc., etc. uNow it is back to modeling.
3
3 Roadmap --- (2) uUML (Unified Modeling Language) --- a more “object-oriented” version of E/R. uODL (Object-Description Langauge) --- a completely object-oriented view of the world. uXML (Extensible Markup Language) --- models data as trees or graphs.
4
4 Roadmap --- (3) uIn the middle, we’ll talk about: wOQL (Object-Query Language) --- the query language built on ODL. wXQuery --- the query language for XML data. Special feature: the XQuery lectures will be given by Don Chamberlin, the inventor of both SQL and XQuery.
5
5 UML uUML is designed to model software, but has been adapted as a database modeling language. uMidway between E/R and ODL. wNo multiway relationships as in E/R. wBut allows attributes on binary relationships, which ODL doesn’t. wHas a graphical notation, unlike ODL.
6
6 Classes uSets of objects, with attributes (state ) and methods (behavior ). uAttributes have types. uPK indicates an attribute in the primary key (optional) of the object. uMethods have declarations = arguments (if any) and return type.
7
7 Example: Bar Class Bar PK Name: string Addr: string setName(n) setAddr(a) getName() : string getAddr() : string sellsBud() : boolean
8
8 Associations uBinary relationships between classes. uRepresented by named lines (no diamonds as in E/R). uMultiplicity at each end. wm..n means between m and n of these associate with one on the other end. w* = “infinity”; e.g. 1..* means “at least one.”
9
9 Example: Association BarBeer 1..50 Sells 0..*
10
10 Comparison With E/R Multiplicities E/R UML 0..* 0..* 0..1 0..* 1..1
11
11 Association Classes uAttributes on associations are permitted. wCalled an association class. wAnalogous to attributes on relationships in E/R.
12
12 Example: Association Class BarBeer 1..50 0..* Sells price: float
13
13 Subclasses uLike E/R, but subclass points to superclass with a line ending in a triangle. uThe subclasses of a class can be: wComplete (every object is in at least one subclass) or partial. wDisjoint (object in at most one subclass) or overlapping.
14
14 Example: Subclasses Beer name: string manf: string Ale color: string
15
15 Conversion to Relations uWe can use any of the three strategies outlined for E/R to convert a class and its subclasses to relations. 1.E/R-style: each subclass’ relation stores only its own attributes, plus key. 2.OO-style: relations store attributes of subclass and all superclasses. 3.Nulls: One relation, with NULL’s as needed.
16
16 Aggregations uRelationships with implication that the objects on one side are “owned by” or are part of objects on the other side. uRepresented by a diamond at the end of the connecting line, at the “owner” side. uImplication that in a relational schema, owned objects are part of owner tuples.
17
17 Example: Aggregation Beer name: string manf: string Award title: string year: int 0..1 Won 0..*
18
18 Compositions uLike aggregations, but with the implication that every object is definitely owned by one object on the other side. uRepresented by solid diamond at owner. uOften used for subobjects or structured attributes.
19
19 Example: Composition Beer name: string manf: string Award title: string year: int 1..1 Won 0..*
20
20 Conversion to Relations uWe could store the awards of a beer with the beer tuple. uRequires an object-relational or nested- relation model for tables, since there is no limit to the number of awards a beer can win.
21
21 Example: Composition Bar name: string phone: int Addr street:string city: string zip: int 1..1 Won 0..1
22
22 Conversion to Relations uSince a bar has at most one address, it is quite feasible to add the street, city, and zip attributes of Addr to the Bars relation. uIn object-relational databases, Addr can be one attribute of Bars, with structure.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.