EER vs. UML Terminology EER Diagram Entity Type Entity Attribute Domain Composite Attribute ~ [Derived Attribute] Relationship Type Relationship Instance Cardinality & Participation UML • • • • • • • • • • UML Class Diagram Class Object Attribute Domain Structured Domain Operation Association Link Multiplicities 1 EER Example E# N Is In 1 D# Department DNAME Employee N NAME FNAME Assigned To M Project LNAME %TIME UML P# PNAME 2 Diagrams EER vs. UML Class E# Employee Employee NAME FNAME Structured Domain E# NAME: NameDom FNAME LNAME Attributes Methods … LNAME Entity Type vs. Class Attribute Composite Attribute vs. Structured Domain UML 3 Department D# DNAME EER vs. UML Complete Diagram … 1..1 Min participation (0 or some int n: n>0) D# E# N Employee Department 1 Is In DNAME Max Cardinality Employee NAME N P# Assigned To LNAME … 0..* AssignedTo %TIME Project P# PNAME %TIME PNAME UML E# NAME: NameDom FNAME LNAME 0..* M Project FNAME 0..* … 4 EER Derived Attributes - Include in Department the average salary of the employees in the department. Employee Member Of Salary Class Method Department AvgSal Department D# DNAME AvgSal UML 5 EER Multi-valued Attributes Student Major EER Multi-valued as Entity Major Student N Has Major 3 Major_Program UML Student … … UML 0..* Major_Program 0..3 Major … 6 Weak Entities EER Weak Entity Employee Name 1 Dependent Name SSN Employee SSN Name … Dependent Name UML Dependents Of N UML Qualified Association Dependent … … 7 Aggregations Location Location Department Project Name Project Name 0..* No … UML No No Name 1..1 Location Name 1..* 0..* Department Name No … … 8 Example: University Database EmpID SSN Person Salary d disjoint o overlap total U • Superclasses & Subclasses • Generalization & Specialization • Inheritance superclass Employee partial subclass Degree Program o Grad Student Name Student Superclass instance must always exist. Major Dept d Undergrad Student Class UML 9 UML Superclass/Subclass Inheritance EER UML Employee EmpID Salary … Person SSN Name … Student MajorDept … UML disjoint d overlapping o GradStudent DegreeProgram … UndergradStudent Class … 10 Object-Oriented Approach Motivation • Object-Oriented Databases (OODB) – Add persistence to object-oriented programming languages UML • Object Relational Databases (ORDBMS) – Add user-defined methods to relational databases – Allow grouping of relations into more complex “objects” 11 Relational is Good For • Fixed format data • Transaction processing: simple short transactions • Concurrency control • Recovery from crashes • Query processing and Query optimization – relational algebra and mathematical logic operations. UML 12 Problems • The relational model has no notion of a single object. • Context with the real world e.g., spatial context. • Aggregation functions may be desired • The notion of re-use cannot be exploited • There may also be versions or variant configurations UML i.e variations of the same design. 13 Problems With the Relational Model - 1 • Nonhomogeneous collection of design objects. • Data Types: images, matrices, vectors; variable length. • Temporal and/or spatial data. • Many data types; few instances of each type. UML 14 Problems With the Relational Model - 2 • Schemas evolve during design. • Long running transactions: "checkout a design". • Versions; design log. UML 15 Problems With the Relational Model - 3 • Functions needed: – Making a design permanent, – Releasing design to production, – Archiving design, – etc. • Library of design objects: – minimize redundancy. UML 16 Object-Oriented Concepts - 1 • Complex Objects: – sets, – bags, – lists, – arrays, – tuples. UML 17 Object-Oriented Concepts - 2 • Object Identity: identify by object id (oid) rather than by an attribute value, never changes. • Encapsulation: Operations and Data available to user. • Implementation hidden. No other operations available. UML 18 Object-Oriented Concepts - 3 • Types and/or Classes: – Type: • Interface and Implementation. • Types declared, checked at compile-time – Class: • Instances created at run-time UML 19 Object-Oriented Concepts - 4 • Class or Type Hierarchies: – Inheritance: both data and function example: student: undergraduate, graduate • Overriding, overloading, and late binding: – Polymorphism UML 20 Object-Oriented Concepts - 5 • Computational Completeness: • Extensibility: – Means to define new types. – User types not distinguished from system types. • Persistence: – Not present in OO programming languages. – Should be implicit not explicit. UML 21 Object-Oriented Concepts - 6 • Secondary Storage Management: • Concurrency: • Recovery: • Ad Hoc Query Facility: UML 22 Review: Object • State (value) • Behavior (operations) – Signature or interface: operation name and arguments – Method or body: implementation • Identified by unique Object Identifier (OID) UML 23 Class • Group of similar objects • Class hierarchies – Inheritance • Persistence must be specified explicitly – Via entry point – Via reachability UML 24 Type Hierarchies and Inheritance (EER – superclass/subclass relationship) PERSON: Name, Address, Birthdate, Age, SSN EMPLOYEE: subtype-of PERSON: Salary, HireDate, Seniority STUDENT: subtype-of PERSON: Major, GPA EMPLOYEE: Name, Address, Birthdate, Age, SSN, Salary, HireDate, Seniority STUDENT: Name, Address, Birthdate, Age, SSN, Major, GPA UML 25 Object Data Management Group (ODMG) • • • • Object Model Object Definition Language (ODL) Object Query Language (OQL) Bindings to object-oriented programming languages – C++, Java, Smalltalk UML 26
© Copyright 2024 ExpyDoc