Discuss the various type constructors. How are they used to create complex object structures?

 Type constructor

  •  A type constructor is used to define the data structure for object-oriented, DB there are six types of a type constructor. 
  • A type constructor is the collection of multiple similar basic types under a common name. It determines how the object is constructed.
  •  The type constructors can be used to define the data structures for an object-oriented database schema. The three basic type constructors are atom, tuple, and set. Other commonly used constructors include list, bag, and array.

a. Atom constructor

This includes the basic built-in data types of the object model, which are similar to the basic types in many programming languages: integers, strings, floating-point numbers, enumerated types, Booleans, and so on. These basic data types are called single-valued or atomic types since each value of the type is considered an atomic (indivisible) single value.

b. Structured type constructor (struct or tuple constructor)

This can create standard structured types, such as the tuples (record types) in the basic relational model. A structured type is made up of several components and is also sometimes referred to as a compound or composite type. More accurately, the struct constructor is not considered to be a type, but rather a type generator, because many different structured types can be created. For example, two different structured types that can be created are:

a. struct Name<FirstName: string, MiddleInitial: char, LastName: string>, and

b. structCollegeDegree<Major: string, Degree: string, Year: date>.

c. Collection (or multivalued) type constructors

To create complex nested type structures in the object model, the collection type constructors are needed. These include the set(T), list(T), bag(T), array(T), and dictionary (K,T) type constructors. These allow part of an object or literal value to include a collection of other objects or values when needed. These constructors are also considered to be type generators because many different types can be created. For example, set(string), set (integer), and set(Employee) are three different types that can be created from the set type constructor. All the elements in a particular collection value must be of the same type. For example, all values in a collection of type set(string) must be string values.

2nd part

A complex type may be constructed from other types by the nesting of type constructors. An object is defined by a tuple (OID, type constructor, state) simply, (i, c, v) where OID is the unique object identifier, type constructor is its type such as atom, tuple, set, array, bag, etc. and state is its actual value.

Example:

(il, atom, 'Aarav')

(12, atom, 50)

(i3, atom, 'Aadesh')

(i4, atom, 'Aabin')

(i5, atom, 'Ashna')

(16, tuple, [name: i1, Age: 13])

(17, set, (14, 15))

(i8, tuple, [name: i3, Friends: i7]) (19, set, (16, 18))

Comments

Popular posts from this blog

Suppose that a data warehouse consists of the three dimensions time, doctor, and patient, and the two measures count and charge, where a charge is the fee that a doctor charges a patient for a visit. a) Draw a schema diagram for the above data warehouse using one of the schemas. [star, snowflake, fact constellation] b) Starting with the base cuboid [day, doctor, patient], what specific OLAP operations should be performed in order to list the total fee collected by each doctor in 2004? c) To obtain the same list, write an SQL query assuming the data are stored in a relational database with the schema fee (day, month, year, doctor, hospital, patient, count, charge)

Suppose that a data warehouse consists of the four dimensions; date, spectator, location, and game, and the two measures, count and charge, where charge is the fee that a spectator pays when watching a game on a given date. Spectators may be students, adults, or seniors, with each category having its own charge rate. a) Draw a star schema diagram for the data b) Starting with the base cuboid [date; spectator; location; game], what specific OLAP operations should perform in order to list the total charge paid by student spectators at GM Place in 2004?

Suppose that a data warehouse for Big-University consists of the following four dimensions: student, course, semester, and instructor, and two measures count and avg_grade. When at the lowest conceptual level (e.g., for a given student, course, semester, and instructor combination), the avg_grade measure stores the actual course grade of the student. At higher conceptual levels, avg_grade stores the average grade for the given combination. a) Draw a snowflake schema diagram for the data warehouse. b) Starting with the base cuboid [student, course, semester, instructor], what specific OLAP operations (e.g., roll-up from semester to year) should one perform in order to list the average grade of CS courses for each BigUniversity student. c) If each dimension has five levels (including all), such as “student < major < status < university < all”, how many cuboids will this cube contain (including the base and apex cuboids)?