Professional Documents
Culture Documents
11-1
Object Identity
unique identity for each independent object stored in the database created by a unique, system-generated object identifier, or OID
11-5
Object Structure
(i, c, v) i: a unique object identifier (OID) c: a type constructor System supports basic type: atom (integer,real,string,Boolean,) order unorder structured type: tuple collection type: array vs. list, set vs. bag
number of elements distinct vs. duplicate
11-7
MINIT B T J
SSN
BDATE
ADDRESS 731 Fondren, ouston, TX 638 Voss, ouston, TX 3321 Castle, pring, TX 291 Berry, Bellaire, TX 975 Fire Oak, umble, TX 5631 ice, ouston, TX
SEX
DNO 5 5 4 4 5 5 4 1
123456789 09-J N-55 333445555 08- EC-45 999887777 19-JU -58 987654321 20-JUN-31 666884444 15- E -52 453453453 31-JU -62 987987987 29-
F F
Narayan English
V E
Jabbar Borg
11-9
i5 : O 5 atom
5
i4 : O 4 i : O 9 9 atom tuple
4
i7 : O 7 set
Research
O1
1
O2
2
O3
3
ellaire Sugarland
string; integer; tuple (manager: Employee; startdate: Date; ); locations: set (string); set of references employees: set (Employee); projects: set (Project); );
11-16
Define the behavior of a type of object based on the operations that can be externally applied to object of that type
create (insert) or destroy (delete) objects update the object state retrieve parts of the object state apply some calculations combination of retrieval, calculation, and update
11-17
define the name and arguments (parameters) of each operation signature (included in the class definition)
implementation
method (defined using programming languages) it is invoked by sending a message to the object to execute the corresponding method 11-18
type definition
definition of operations
11-19
type definition
Employee; Date; );
definition of operations
operations number_of_emps : integer; create_dept: Department, destroy_dept: boolean; assign_emp (e: Employee): boolean; (* adds a new employee to the department *) remove_emp (e: Employee): boolean; (* removes an employee from the department *) end Department;
11-20
Class Operations
object constructor
create a new object
destructor
destroy an object
object modifier
modify various attribute of an object
dot notation
d.no_of_emps where d is a reference to a department object and no_of_emps is an operation
refer to attributes of an object: d.dnumber, d.mgr.startdate
11-21
persistent object
stored in the database and persist after program termination
naming mechanism
give an object a unique persistent name through which it can be retrieved by this and other program
11-22
Reachability
reachability mechanism
make the object reachable from some persistent object an object is said to be reachable from an object A if a sequence of references in the object graph lead from object A to object e.g., if o8 is persistent, then all other objects also become persistent (next slide) defines a persistent collection of objects of class C create a named persistent object , whose state is a set or list of objects of some class C add objects of C to the set or list and make them reachable from
11-23
i5 : O 5 atom
5
i4 : O 4 i : O 9 9 atom tuple
4
i7 : O 7 set
Research
O1
1
O2
2
O3
3
ellaire Sugarland
persistent name AllDepartments: DepartmentSet ; (* AllDepartments is a persistent named object of type set DepartmentSet*)
.....
d := create_dept ; ..... (* creates a new department object in the variable d *) b := AllDepartments.add_dept (d) ; (* make d persistent by adding it to the persistent named object AllDepartments *) AllDepartments object: extent of the class Department
11-25
OO approaches
a class declaration specifies only the type and operations for a class of objects user must define a persistent object whose value is the collection of references to all 11-26 persistent
TYPE_ AME: function, function, , function PERSO : ame, Address, irthdate, Age, SS EMPLOYEE subtype-of PERSO : Salary, HireDate, Seniority ST DE T subtype-of PERSO : Major, GPA
11-27
GEOMETRY_O JECT: Shape, Area, ReferencePoint RECTA GLE subtype-of GEOMETRY_O JECT: Width, Height
method attribute
TRIA GLE subtype-of GEOMETRY_O JECT: Side1, Side2, Side3 CIRCLE subtype-of GEOMETRY_O JECT: Radius
11-28
CIRCLE subtype-of
GEOMETRY_O JECT (Shape=circle): Radius
11-29
Inheritance
multiple inheritance
when T is a subtype of two (or more) types, T inherits the functions (attributes and methods) of both supertypes type lattice instead of type hierarchy if a function is inherited from some common supertype, it is inherited only once ambiguity resolution
alarm users system default disallow multiple inheritance
11-30
Inheritance (Continued)
Selective Inheritance
a subtype inherits only some of the functions of a supertype an E CEPT clause may be used to list the functions in a super type that are not to be inherited by the subtype
11-31