Chapter-2-Database-Models.docx
Chapter-2-Database-Models.docx
Introduction
A database model shows the logical structure of a database, including the relationships
and constraints that determine how data can be stored and accessed. Individual
database models are designed based on the rules and concepts of whichever broader
data model the designers adopt. Most data models can be represented by an
accompanying database diagram (The Computer Revolution/Databases/Database
Models, Wikibooks).
I. Hierarchical Databases
Hierarchical databases are the oldest database models. Unlike other models, they do not
have a well-documented history. The hierarchical database was the first one developed
and therefore was commonly used in the first mainframe database management
systems. They were developed out of the 1950s and 60s Information Management
Systems. Many banks and insurance companies, as well as government departments
and hospitals (for inventory and accounting systems) still use them today.
The hierarchical database stores data in a series of records. These records have a set of
field values attached to them. All instances of a specific record are collected as a "record
type". It uses "Parent-Child Relationships" to create links between record types. It does
this by using trees. However, it is only able to cope with one tree. Also, there can only be
one parent per child, and no relationships among the child records are possible.
Network Databases
Types of networks:
Charles Bachman invented the network database model. The network database
model is similar to the hierarchical model but allows child tables to have multiple
parents using set theory. This structure supports many relationships, resembling
interconnected trees where branches are shared. Parents and children can have
multiple connections, enhancing data flexibility.
A relational database stores data in separate related tables and combines data as
needed for queries and reports. Developed by Edgar Codd in 1970, it was designed
to support flexible, ad hoc data retrieval. Most modern DBMS, such as Oracle, DB2,
SQL Server, and MySQL, follow this model.
Properties of Relational Databases
● Atomic Values – Columns do not contain repeating groups, simplifying data
manipulation.
● Unique Column & Row Names – Each column and row has a distinct name
for identification.
● Unique Rows – No duplicate rows, ensuring data integrity.
● Order Independence – The sequence of rows and columns does not affect
data retrieval.
● Consistent Column Data – Each column contains values of the same type
and unit.
Example:
Sample Entity and Attributes
Entity: Student
Description: Represents a student in a school database.
This Student entity can be related to other entities like Course or Enrollment using
keys (e.g., Course_ID as a foreign key linking to the Course table).
1. Super Key
A super key is a set of one or more attributes that uniquely identify a record in a
table. It may contain extra attributes that are not necessary for uniqueness.
Example:
For a Student entity:
Attribute Description
Student_ID
Unique student identifier
(PK)
Email Unique email address
Phone_Numbe
Contact number
r
● Possible Super Keys:
o {Student_ID} (Minimal and unique)
o {Student_ID, Email} (Extra attribute but still unique)
o {Student_ID, Phone_Number, Email} (Still unique but unnecessary
attributes included)
2. Composite Key
A composite key consists of two or more attributes that together uniquely identify a
record.
Example:
For an Enrollment entity (which tracks student enrollment in courses):
Attribute Description
References Student
Student_ID (FK)
table
Course_ID (FK) References Course table
Enrollment_Date Date of enrollment
● Composite Key: {Student_ID, Course_ID}
o A student can enroll in multiple courses, and a course can have multiple
students, so both Student_ID and Course_ID together uniquely
identify an enrollment record.
3. Alternate Key
An alternate key is a candidate key that is not chosen as the primary key.
Example:
For a Student entity:
Attribute Description
Student_ID (PK) Unique student identifier
Email (Unique) Unique email address
Phone_Number
Unique phone number
(Unique)
● Candidate Keys:
o {Student_ID} (Chosen as Primary Key)
o {Email} (Could be a Primary Key, but not chosen → Alternate Key)
o {Phone_Number} (Another Alternate Key)
Flexibility
Relational Databases: Effective for structured data but less flexible for complex
relationships, requiring multiple tables and joins.
Object-Oriented Databases: Easily handle complex data structures and relationships,
ideal for applications like multimedia, engineering, and simulations.
Example:
Book Class
Attribute Description
Book_ID Unique identifier for the book
Title Title of the book
Author Author of the book
Publisher Publisher of the book
Publication_Year Year the book was published
International Standard Book
ISBN
Number
Methods checkout(), return_book(), reserve()
learn.saylor.org