📌 Chapter 1.2 – Object Identity, Object Structure, and Type Constructors
👋 Hi, Ethio students! Welcome back. Today we dig deep into object identity, the (i, c, v) triple, and the constructors that build complex objects. Everything is from your CoSc 2042 module. Let’s make it crystal clear! 🇪🇹
🔐 1.2.1 Object Identity (OID) – the soul of an object
In an object‑oriented database, every object is given a unique, never‑changing object identifier (OID). It’s like a fingerprint or a national ID number (like your Ethiopian passport number) but for the database. No matter how the object’s data changes, the OID stays the same.
The PDF states: “OID is not visible to the external user, but it is used internally to identify each object uniquely and to create inter‑object references.” So you never see it, but the database uses it everywhere.
💡 Example – two students with same name:
Student table (conceptual)
------------------------------------------------
| OID (hidden) | name | department |
------------------------------------------------
| 0x9A2C1 | Abebe | Computer Science |
| 0x9A2C2 | Abebe | Software Eng |
------------------------------------------------
Even if both are called Abebe, OIDs are unique. If Abebe changes his dept, OID 0x9A2C1 remains.
✨ Two main properties of OID
- Immutable – never changes after creation.
- Single‑use – even if the object is deleted, its OID is never assigned to another object. (like a burnt Ethiopian birr note – we never reuse serial numbers)
Forms of identity in computer systems (important for exam)
| Identity type | Description | Example |
|---|---|---|
| Value‑based | identity by data values (primary key) | Relational primary key (e.g., student ID = 1234) |
| Name‑based | user‑supplied name | variable name in a program, file path |
| Built‑in (OID) | system‑generated, invisible, never changes | Object‑oriented databases, OIDs |
🔔 Remember: OODBS uses built‑in identity. No user‑supplied identifier is required.
📘 Exam tip – Mid/Ethio Exit: They often ask: “Which identity form is used in OODBS?” or “List two properties of OID.” Also be ready to contrast OID with relational primary key. Primary key can change if you update a value, but OID never changes.
📝 Practice questions – Object Identity
Q1 (exit style): In an object‑oriented database, the object identifier (OID) has which of the following characteristics?
A) It can be modified by the user if needed
B) It is reused immediately after object deletion
C) It is immutable and each OID is used only once
D) It is based on the object’s primary key value
Q2: Which form of identity is used in object‑oriented database systems?
A) Value‑based (primary key)
B) User‑supplied name
C) Built‑in identity
D) File path
Q3 (true/false): If an object’s attributes are all changed, its OID remains the same. (True/False)
🧩 1.2.2 Object Structure – the (i, c, v) triple
The PDF gives us a formal way: every object can be viewed as a triple (i, c, v) where:
- i = unique object identifier (OID)
- c = type constructor (how the state is built: atom, tuple, set, list …)
- v = object state (current value)
This allows objects to be nested: a set can contain tuples that contain atoms, etc.
🔍 Example – a University object (simplified):
(i: OID_U001,
c: tuple,
v: < name: "AAU",
students: (i: OID_S100, c: set, v: { S1, S2, S3 })
> )
We see nesting: tuple constructor contains an atom (name) and a set (students). Each student is another object.
🏗️ The three most basic type constructors
From page 9 of the PDF: atom, tuple, set are the core. Then we have list, bag, array as extra.
| Constructor | Meaning | Example value (v) | Usage |
|---|---|---|---|
| Atom | basic atomic values | 25, ‘Ethiopia’, true, 3.14 | integers, strings, booleans |
| Tuple | record with named fields | <fname: ‘Azeb’, lname: ‘Wondimu’> | structured data (like a row) |
| Set | unordered collection, no duplicates | { oid1, oid2, oid3 } | many-to-many relationships |
| List | ordered, duplicates allowed | [ ‘A’, ‘B’, ‘A’ ] | ordered data |
Think of constructors as ways to build complex objects from simpler pieces. Like we use cement, bricks, wood to build a house – we combine atoms, tuples, sets to build any real‑world object.
🌰 More examples from the PDF idea:
(oid101, atom, 1996) // a simple integer
(oid102, tuple, < city: "Addis", pop: 5e6 >) // tuple with two fields
(oid103, set, { oid101, oid104, oid105 }) // set of OIDs (references)
📝 Practice – object structure & constructors
Q4: In the triple (i, c, v), what does ‘c’ represent?
A) object identifier
B) constructor indicating how state is built
C) current class name
D) collection
Q5: Which constructor would you use to represent a student’s list of grades in order (with possible repeated scores)?
A) set
B) atom
C) tuple
D) list
Q6 (exit): A complex object in OODB can have arbitrary nesting of constructors. Which of the following is valid?
A) set of tuples
B) tuple containing an atom and a set
C) list of sets
D) all of the above
⚙️ 1.2.3 Deep dive – atom, tuple, set (and friends)
Let’s look more closely at each constructor from the exam point of view.
⚛️ Atom constructor
The atom constructor represents simple, built‑in data types: integers, floats, chars, strings, booleans. It’s the leaf of the object tree. From PDF: “used to represent all basic atomic values”.
✅ Atom examples: (oid200, atom, 100) (oid201, atom, "Debre Zeit") (oid202, atom, false)
📦 Tuple constructor
Tuple is like a record or struct with field names. It groups related values. Important: fields can be atoms or even other objects (via OID).
(oid300, tuple, < courseCode: "CoSc2042",
title: "Advanced DB",
credits: 5,
instructor: oid301 >)
Here the instructor field is an OID referencing another object.
🔗 Set constructor
A set holds an unordered collection of objects/values with no duplicates. Perfect for representing relationships like “courses a student is enrolled in”.
(oid400, set, { oid401, oid402, oid403 }) // set of three OIDs
➕ Other constructors (list, bag, array)
- List: ordered, may have duplicates. e.g., to-do list.
- Bag: unordered, allows duplicates (like a multiset).
- Array: fixed‑size indexed collection.
| Constructor | Order? | Duplicates? | Typical use |
|---|---|---|---|
| Atom | – | – | simple values |
| Tuple | by field name | N/A | records |
| Set | no | no | unique collections |
| List | yes | yes | ordered data, e.g., timeline |
| Bag | no | yes | multiset, e.g., inventory with counts |
Q7 (Mid): Which constructor should be used to represent a set of phone numbers assigned to a person, assuming a person cannot have the same number twice?
A) list
B) bag
C) set
D) tuple
Q8 (design): An order object contains order lines, and the lines must be kept in the order they were entered. Which constructor is appropriate for the lines?
A) set
B) bag
C) list
D) atom
Q9: True or False: A tuple constructor can contain an atom as a field value, and also a set as another field.
🎯 Putting it all together – why this matters for your exam
Object identity and constructors are the foundation of OODB. You’ll face questions like:
- “Explain the (i,c,v) model with an example.”
- “Differentiate between set and list constructors.”
- “Why is OID immutable?”
📌 Common mistakes to avoid
❌ Thinking OID is same as primary key – primary key is value‑based, OID is built‑in.
❌ Mixing up set (no duplicates) and bag (duplicates allowed).
❌ Forgetting that tuples have named fields (unlike lists).
📝 Mixed practice (Exit exam level)
Q10: Given the following object: (oid52, tuple, <a: (oid53, atom, 10), b: (oid54, set, {1,2,3})>). Which statement is correct?
A) The object has nested constructors – tuple contains atom and set
B) It is invalid because a tuple cannot contain a set
C) The OID of the inner set is oid52
D) The set constructor contains tuples
Q11: Why do OODB systems use built‑in identity instead of value‑based identity? (short answer)
🧾 Quick summary – what we studied
- OID – immutable, single‑use, built‑in identity.
- Object structure = (i, c, v).
- Three basic constructors: atom (basic values), tuple (record), set (unordered unique).
- Nesting is allowed: set of tuples, tuple with set, etc.
- Other constructors: list (ordered), bag (duplicates allowed), array.
✨ Keep practising, Ethio students! You’ll master OODB. Tell your friends about ethiotemari.com.