Temporal, Geographical and Categorical Aggregations Viewed ...
1 Unified Modeling Language Classes Associations Aggregations.
-
date post
21-Dec-2015 -
Category
Documents
-
view
226 -
download
1
Transcript of 1 Unified Modeling Language Classes Associations Aggregations.
![Page 1: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/1.jpg)
1
Unified Modeling Language
ClassesAssociationsAggregations
![Page 2: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/2.jpg)
2
A Bit of Roadmap
We started with modeling: E/R and relational.
We then spent 5 weeks talking about various aspects of database programming: SQL, JDBC, relational algebra, etc., etc.
Now it is back to modeling.
![Page 3: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/3.jpg)
3
Roadmap --- (2)
UML (Unified Modeling Language) --- a more “object-oriented” version of E/R.
ODL (Object-Description Langauge) --- a completely object-oriented view of the world.
XML (Extensible Markup Language) --- models data as trees or graphs.
![Page 4: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/4.jpg)
4
Roadmap --- (3)
In the middle, we’ll talk about: OQL (Object-Query Language) --- the
query language built on ODL. XQuery --- the query language for
XML data.• Special feature: the XQuery lectures will
be given by Don Chamberlin, the inventor of both SQL and XQuery.
![Page 5: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/5.jpg)
5
UML
UML is designed to model software, but has been adapted as a database modeling language.
Midway between E/R and ODL. No multiway relationships as in E/R. But allows attributes on binary
relationships, which ODL doesn’t. Has a graphical notation, unlike ODL.
![Page 6: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/6.jpg)
6
Classes
Sets of objects, with attributes (state ) and methods (behavior ).
Attributes have types. PK indicates an attribute in the
primary key (optional) of the object. Methods have declarations =
arguments (if any) and return type.
![Page 7: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/7.jpg)
7
Example: Bar Class
Bar
PK Name: string Addr: string
setName(n)setAddr(a)getName() : stringgetAddr() : stringsellsBud() : boolean
![Page 8: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/8.jpg)
8
Associations
Binary relationships between classes. Represented by named lines (no
diamonds as in E/R). Multiplicity at each end.
m ..n means between m and n of these associate with one on the other end.
* = “infinity”; e.g. 1..* means “at least one.”
![Page 9: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/9.jpg)
9
Example: Association
Bar Beer1..50 Sells 0..*
![Page 10: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/10.jpg)
10
Comparison With E/R Multiplicities
E/R UML0..* 0..*
0..* 0..1
0..* 1..1
![Page 11: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/11.jpg)
11
Association Classes
Attributes on associations are permitted. Called an association class. Analogous to attributes on
relationships in E/R.
![Page 12: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/12.jpg)
12
Example: Association Class
Bar Beer1..50 0..*
Sellsprice: float
![Page 13: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/13.jpg)
13
Subclasses
Like E/R, but subclass points to superclass with a line ending in a triangle.
The subclasses of a class can be: Complete (every object is in at least
one subclass) or partial. Disjoint (object in at most one
subclass) or overlapping.
![Page 14: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/14.jpg)
14
Example: Subclasses
Beername: stringmanf: string
Alecolor: string
![Page 15: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/15.jpg)
15
Conversion to Relations
We 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.
![Page 16: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/16.jpg)
16
Aggregations
Relationships with implication that the objects on one side are “owned by” or are part of objects on the other side.
Represented by a diamond at the end of the connecting line, at the “owner” side.
Implication that in a relational schema, owned objects are part of owner tuples.
![Page 17: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/17.jpg)
17
Example: Aggregation
Beername: stringmanf: string
Awardtitle: stringyear: int
0..1 Won 0..*
![Page 18: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/18.jpg)
18
Compositions
Like aggregations, but with the implication that every object is definitely owned by one object on the other side.
Represented by solid diamond at owner.
Often used for subobjects or structured attributes.
![Page 19: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/19.jpg)
19
Example: Composition
Beername: stringmanf: string
Awardtitle: stringyear: int
1..1 Won 0..*
![Page 20: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/20.jpg)
20
Conversion to Relations
We could store the awards of a beer with the beer tuple.
Requires an object-relational or nested-relation model for tables, since there is no limit to the number of awards a beer can win.
![Page 21: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/21.jpg)
21
Example: Composition
Barname: stringphone: int
Addrstreet:stringcity: stringzip: int
1..1 Won 0..1
![Page 22: 1 Unified Modeling Language Classes Associations Aggregations.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649d565503460f94a3480d/html5/thumbnails/22.jpg)
22
Conversion to Relations
Since 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.
In object-relational databases, Addr can be one attribute of Bars, with structure.