0% found this document useful (0 votes)
14 views8 pages

Chapter-2-Database-Models.docx

Chapter 2 discusses various database models, including hierarchical, network, relational, and object-oriented models, each with distinct structures and use cases. Hierarchical databases organize data in a tree-like structure, while network databases allow multiple parent-child relationships. Relational databases store data in tables based on relationships, and object-oriented databases manage data as objects, offering flexibility for complex data structures.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views8 pages

Chapter-2-Database-Models.docx

Chapter 2 discusses various database models, including hierarchical, network, relational, and object-oriented models, each with distinct structures and use cases. Hierarchical databases organize data in a tree-like structure, while network databases allow multiple parent-child relationships. Relational databases store data in tables based on relationships, and object-oriented databases manage data as objects, offering flexibility for complex data structures.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Chapter 2: Database Models

Chapter 1: Unlocking the Power of Databases

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).

The logical arrangement and structure of the data in a database is defined by a


database model. It acts as the guide for managing, accessing, and storing data in a
database management system (DBMS). Depending on the particular use case and
needs, many database models are created to maximize data integrity, retrieval, and
storage.

There are several types of database models, including:

1.​ Hierarchical Model – Organizes data in a tree-like structure with parent-child


relationships.
2.​ Network Model – Uses a graph structure with multiple relationships between
records.
3.​ Relational Model – Represents data in tables with rows and columns,
following a structured schema.
4.​ Object-Oriented Model – Incorporates object-oriented programming principles
to manage complex data types.
5.​ NoSQL Models – Includes document, key-value, column-family, and
graph-based databases designed for scalability and flexibility.

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.

As an example, we could have a tree representing a university department, with


subtrees representing staff members, students, courses, and facilities. We could have
numerous department trees, but we could not have one employee working for more than
one department. In order to do this, we would have to create two instances of the
employee. Obviously, this would create inaccuracies when updating information, as the
information might not be the same for all records. There is also the issue of data
repetition in various records.
A hierarchical database has a very structured form, as it allows no links between layers
in different branches of the tree. Therefore, it is easy to use for adding, updating, and
deleting records.

Advantages of the Database


●​ it is easy to design
●​ it is cheap to maintain
●​ it is easy to use
●​ as all data are stored in a common database, it implies data sharing and security
can be inforced
●​ a certain degree of data independence can be maintained

Shortcomings of the Database


●​ The hierarchical database is inflexible to information, for example; in a college
setting, students may have a variety of classes/courses, but the hierarchical
database is going to show only one of them and to the database, the others don't
exist.
●​ Relationships are difficult to implement in a hierarchical model.
●​ Extensive programming activities required. Navigation inside the tree is
complicated.
●​ Difficult to solve the problem of a single child with multiple parents
●​ Difficult to navigate through: with the exception of the root record, all records
have to be accessed through the parent.
●​ Alteration of data is difficult due to rules governing the relationship of records.
Currently, this type of database is not utilized to its full potential.

Network Databases
Types of networks:

●​ Wide area Network WAN - a communication network that covers a wide


geographical area. i.e. long-distance telephone companies
●​ Metropolitan Area Network MAN - a communication network that covers a city or
suburb. i.e. local telephone companies and many cell phone companies
●​ Local Area Network LAN - connects computers and devices in a limited
geographic area. i.e. universities
●​ Home Area Network HAN - wired cable or wireless networks. i.e. computers,
printers, VCR, TV, home security systems.
●​ Personal Area Network PAN - slightly different from HAN, because it doesn't use
wires, it uses short-range wireless technology. i.e. cell phones, PDAs, MP3
players, and Bluetooth.

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.

Benefits of the Network Database Model


1.​ Flexible Relationships – Supports multiple parent-child relationships, allowing
complex data modeling.
2.​ Efficient Data Management – Enables updates, replacements, and security
measures against certain attacks.
3.​ General Services – Provides online access to client and job databases, 24/7
availability, and data sharing.
4.​ Research Services – Offers research assistance, candidate screening, and
reference checks.
5.​ Technology Services – Includes firewall security, virus protection, system setup,
training, database maintenance, and technical support.

Relational Database Model


A relational database is a database system in which any database file can be a
component of more than one of the database's tables. It is also a database system in
which the database is organized and accessed according to the relationships
between data items without the need for any consideration of physical orientation
and relationship. Relationships between data items are expressed by means of
tables.

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.

What Are Keys in a Database?


In a database, a key is an attribute (or a set of attributes) used to uniquely identify
records within a table. Keys ensure data integrity, help establish relationships
between tables, and improve data retrieval efficiency.

Types of Keys in a Database


Candidate Key – A field or combination of fields that uniquely identifies a record.
Primary Key – A chosen candidate key that uniquely identifies records in a table.
Foreign Key – A field that references a key in another table to establish
relationships.
Super Key – A set of attributes that uniquely identify a record but may include extra,
unnecessary fields.
Composite Key – A key made up of multiple fields to uniquely identify a record.
Alternate Key – A candidate key not chosen as the primary key.
Unique Key – A field that ensures uniqueness like a primary key but allows null
values.

Example:
Sample Entity and Attributes
Entity: Student​
Description: Represents a student in a school database.

Attribute Description Data Type


Student_ID (Primary
Unique identifier for each student Integer
Key)
First_Name Student's first name Varchar(50)
Last_Name Student's last name Varchar(50)
Date_of_Birth Student’s birthdate Date
Gender Student’s gender Varchar(10)
Email Student’s email address Varchar(100)
Phone_Number Contact number Varchar(15)
Address Home address Varchar(255)
Course_ID (Foreign References the course the student is
Integer
Key) enrolled in

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)

Object Oriented Database Model


An object-oriented database stores data as objects, similar to how certain programming
languages manage data. Instead of tables with rows and columns like traditional
databases, object databases use complex data structures to represent data.

What are objects?


Objects in programming are like smart containers that hold the data, as well as the
actions that are performed on the data.

Here is a simple breakdown of an object:


●​ Data: This is the stored information. For example, a customer data “object” would
include details like the customer's name, address, phone number, and email.
●​ Actions (methods): Actions are the things that can be done with the data. For
example, there may be specific actions needed to update the customer's address
or to retrieve their order history.
Differences Between Relational and Object-Oriented Databases
(OODBs)
Structure
Relational Databases: Data is organized in tables with rows (records) and columns
(attributes).
Object-Oriented Databases: Data is stored as objects, which can encapsulate both data
and actions.

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.

Objects and classes


In an OODB, data is organized into objects and classes, mirroring the structure of
object-oriented programming languages. In programming, a class acts as a blueprint for
creating objects, specifying both the data structure and the behaviors the objects will
have.
Example: book class
Consider a "book" class in a library database. This class might include attributes such as
title, author, ISBN, and publication year, along with methods to manage the book's data.
Each book in the library is an instance of the "book" class, containing actual data and the
ability to perform actions related to data management.
Attributes: Title, Author, ISBN, Publication Year
Actions:
●​ checkOut() updates the database status to "Checked Out."
●​ returnBook() updates the database status to "Available."
●​ updateStatus("Reserved") updates the database status to "Reserved.”

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()

How Inheritance and Polymorphism Boost Flexibility in OODBs


●​ Inheritance allows a new class to inherit attributes and methods from an existing
class, promoting code reuse and hierarchical organization. For example, a
"preferred customer" class can inherit from the "customer" class and add unique
features like a discount rate.

●​ Polymorphism allows different objects to be treated as instances of the same


class through a shared interface. This increases flexibility by enabling the same
method to work on different objects, like printing customer information for both
regular and preferred customers without separate methods.
Real-world applications of OODBs
Industries Where Object-Oriented Databases Are Beneficial
1.​ Computer-Aided Design and Manufacturing (CAD/CAM)​
OODBs excel at managing complex design models and manufacturing processes
by storing detailed geometric and structural data as objects, making modifications
easier.
2.​ Telecommunications​
OODBs efficiently handle vast interconnected data, such as network
configurations, call records, and customer information, where relationships
between data points are crucial.

3.​ Scientific Research​


In fields like bioinformatics, physics, and environmental science, OODBs manage
large, complex datasets, aiding in data modeling and analysis for discoveries and
innovations.

4.​ Multimedia Applications​


OODBs are ideal for managing multimedia content (images, videos, audio) by
storing metadata as objects, making the organization and retrieval of such
content more efficient.
References:
The Computer Revolution/Databases/Database Models - Wikibooks, open books for an
open world. (n.d.). Retrieved February 13, 2025, from
https://en.wikibooks.org/wiki/The_Computer_Revolution/Databases/Database_M
odels

MongoDB. (n.d.). What is an Object-Oriented Database?


https://www.mongodb.com/resources/basics/databases/what-is-an-object-oriented-
database

learn.saylor.org

You might also like