Com 322 Database 2
Com 322 Database 2
(DECCOMS)
IN AFFILIATION WITH
TEMPLE GATE POLYTECHNIC
ABA, ABIA STATE.
COURSE TITLE: DATABASE DESIGN 2
COURSE CODE: COM 322 DEPARTMENTS: COMPUTER SCIENCE
TIME ALLOWED: 2 HOURS INSTRUCTIONS: ANSWER FIVE QUESTIONS
QUESTION 1
1a. What is an object-oriented database (2 marks)
1b. Where Are Object-Oriented Databases Used? (4 marks)
1c. Explain the various components of Object-Oriented Data Models (8 marks)
QUESTION 2
2a. What is the difference between a relational database and object-oriented (4 marks)
2b. What Are the Advantages of Object-Oriented Databases? (4 marks)
2c. What Are the Disadvantages of Object-Oriented Databases? (6 marks)
QUESTION 3
3a. Define the following terms
Functional dependency
Armstrong’s axioms
Trivial functional dependency
Normalization (8 marks)
3b. what do you understand by “join” (2 marks)
3c. Write down the signs/symbols of the following terms
Theta
Notation
Natural join
Full outer join (4 MARKS)
QUESTION 4
4a. Explain the various categories that storage device can be categorized (9 marks)
4b. Explain Redundant Array of Independent Disks. Give examples (3 marks)
4c. Name two types of file organization (2 marks)
QUESTION 5
5a. File operations can be broadly classified into two categories. Discuss these categories
(4 marks)
5b. Explain the three types of index attributes (6 marks)
5c. Write short notes on sparse index and multilevel index (4 marks)
QUESTION 6
6a. Define Query Processing and highlight three steps involved (5 marks)
6b. A transaction is a very small unit of a program and it may contain several low level tasks. A
transaction in a database system must maintain “ACID properties”. Using the acronym, explain
the terms. (10 marks)
QUESTION 7
7a. Write short notes on the following terms
Result equivalence
View equivalence
Conflict equivalence (12 marks)
An object-oriented database (OOD) is a database system that can work with complex data
objects — that is, objects that mirror those used in object-oriented programming languages.
OODs are most often used with object-oriented programming languages like Java, Kotlin, C#,
Node JS (React), and Swift. Industries that use OODs are typically those built on an object-
oriented language and wanting to boost productivity while working with complex data structures.
One good example of an OOD is online IT training provider CBT Nuggets. CBT Nuggets uses
Realm to offer more than 5,000 courses ranging from basic computer skills to complex network
management (see this case study). CBT Nuggets works to ensure subscribers can view content
from anywhere, at any time. To meet this promise, classes are delivered through streaming
videos that range from 10- to 20-minute “nuggets.” Content is available on both desktop and
through a mobile app.
With the Realm and MongoDB Atlas Device Sync, CBT was able to develop using the cross-
platform SDKS for Android and iOS devices using direct object-to-business class mapping and
seamless sync to MongoDB Atlas.
Object: A real world entity, such as a specific life task in a to-do list-“take the garbage
out”.
Attributes and Methods: An object has state and behaviors. An object has properties
(which might also be called attributes) like name, status, and create_date. The set of
properties taken together represents its state. Along with this, an object has behaviors
(also known as methods, actions, or functions) that modify or operate on its properties,
like update_task() or get_task_history().
Class: The grouping of all objects with the same properties and behaviors form a class. In
our example above, we talked about task objects. These objects together all belong to
the Task class.
2a. What is the difference between a relational database and object-oriented (4 marks)
Relational database management systems (RDBMS) work with tables, with each row in the table
representing a record. The columns in a row represent the attributes of an individual record.
Associations between records (“A Company has many Employees. An Employee belongs to a
Company”) are facilitated with foreign keys in one table referencing IDs in another table. These
associations make up the “relational” part of relational databases.
Data values stored in relational databases are atomic and primitive. By primitive, we mean that
they are types like characters, text strings, numbers, and hashes. Even though MySQL and
SQLite support the JSON (JavaScript Object Notation) data type, that’s not the same as
supporting objects in the sense that OODs do.
Contrast this with the OOD, which typically stores and manages objects directly on the database
server’s disk. There are no tables, no rows, no columns, no foreign keys. There are only objects.
Associations between objects in an OOD can also be established and persist, which can lead to
powerful and fast querying of data across complex relationships.
With all of their complex associations to other objects, and because mplex data objects persist in
an OOD, the most significant advantage of the OOD over RDBMS is the ability to query across
these complex relationships very quickly.
There are no slow “joins” as in an RDBMS. Instead, you have fast queries with complex
data.
Since the database structure is so close to the programming objects, the code is simpler
and lighter.
As another example, we might think back to our task object instance, which cannot be stored as-
is in MySQL. It needs first to be decomposed into its attributes to be stored in the table as a row
with columns. The reverse process will involve retrieval and composition. Not so with object-
oriented or document databases. Have an object? Store the whole thing in the database.
An OOD may be a great choice if you’re using an object-oriented programming language and
need to manage complex data with complex object-to-object associations. Designing and
optimizing a database system for these kinds of complexities, however, also has its trade-offs.
For one thing, the relative performance of very simple database operations — the ones you might
do for a simple lookup of an attribute from a relational database table— may be sub-optimal.
Additionally, while users of RDBMS can enjoy a standard query language (SQL), users of
object-oriented database systems may not have widely adopted standards at their disposal. For
the most part, each flavor of OOD is coupled tightly to an object-oriented programming
language, and querying syntax is very language-dependent.
Lastly, the OOD user community still feels small in comparison to the exploding ecosystem of
web development within the RDBMS space. But the community is fast-growing and likely to
make up for lost time.
Functional dependency
Armstrong’s axioms
Normalization (8 marks)
Functional Dependency
Armstrong's Axioms
If F is a set of functional dependencies then the closure of F, denoted as F +, is the set of all
functional dependencies logically implied by F. Armstrong's Axioms are a set of rules, that when
applied repeatedly, generates a closure of functional dependencies.
Reflexive rule − If alpha is a set of attributes and beta is_subset_of alpha, then alpha
holds beta.
Augmentation rule − If a → b holds and y is attribute set, then ay → by also holds. That
is adding attributes in dependencies, does not change the basic dependencies.
Transitivity rule − Same as transitive rule in algebra, if a → b holds and b → c holds,
then a → c also holds. a → b is called as a functionally that determines b.
Normalization
If a database design is not perfect, it may contain anomalies, which are like a bad dream for any
database administrator. Managing a database with anomalies is next to impossible.
Update anomalies − If data items are scattered and are not linked to each other properly,
then it could lead to strange situations. For example, when we try to update one data item
having its copies scattered over several places, a few instances get updated properly while
a few others are left with old values. Such instances leave the database in an inconsistent
state.
Deletion anomalies − We tried to delete a record, but parts of it was left undeleted
because of unawareness, the data is also saved somewhere else.
Insert anomalies − We tried to insert data in a record that does not exist at all.
Normalization is a method to remove all these anomalies and bring the database to a consistent
state.
3b. what do you understand by “join” (2 marks)
4a. Explain the various categories that storage device can be categorized (9 marks)
CHAPTER TWO
FILE AND PHYSICAL STORAGE
Databases are stored in file formats, which contain records. At physical level, the actual data is
stored in electromagnetic format on some device. These storage devices can be broadly
categorized into three types −
Primary Storage − The memory storage that is directly accessible to the CPU comes
under this category. CPU's internal memory (registers), fast memory (cache), and main
memory (RAM) are directly accessible to the CPU, as they are all placed on the
motherboard or CPU chipset. This storage is typically very small, ultra-fast, and volatile.
Primary storage requires continuous power supply in order to maintain its state. In case of
a power failure, all its data is lost.
Secondary Storage − Secondary storage devices are used to store data for future use or
as backup. Secondary storage includes memory devices that are not a part of the CPU
chipset or motherboard, for example, magnetic disks, optical disks (DVD, CD, etc.), hard
disks, flash drives, and magnetic tapes.
Tertiary Storage − Tertiary storage is used to store huge volumes of data. Since such
storage devices are external to the computer system, they are the slowest in speed. These
storage devices are mostly used to take the back up of an entire system. Optical disks and
magnetic tapes are widely used as tertiary storage.
File Operations
5c. Write short notes on sparse index and multilevel index (4 marks)
Sparse Index
In sparse index, index records are not created for every search key. An index record here
contains a search key and an actual pointer to the data on the disk. To search a record, we first
proceed by index record and reach at the actual location of the data. If the data we are looking for
is not where we directly reach by following the index, then the system starts sequential search
until the desired data is found.
Multilevel Index
Index records comprise search-key values and data pointers. Multilevel index is stored on the
disk along with the actual database files. As the size of the database grows, so does the size of
the indices. There is an immense need to keep the index records in the main memory so as to
speed up the search operations. If single-level index is used, then a large size index cannot be
kept in memory which leads to multiple disk accesses.
6a. Define Query Processing and highlight three steps involved (5 marks)
Query Processing is the activity performed in extracting data from the database. In
query processing, it takes various steps for fetching the data from the database. The
steps involved are:
2. Optimization
3. Evaluation
6b. A transaction is a very small unit of a program and it may contain several low level tasks. A
transaction in a database system must maintain “ACID properties”. Using the acronym, explain
the terms. (10 marks)
Atomicity − This property states that a transaction must be treated as an atomic unit, that
is, either all of its operations are executed or none. There must be no state in a database
where a transaction is left partially completed. States should be defined either before the
execution of the transaction or after the execution/abortion/failure of the transaction.
Consistency − The database must remain in a consistent state after any transaction. No
transaction should have any adverse effect on the data residing in the database. If the
database was in a consistent state before the execution of a transaction, it must remain
consistent after the execution of the transaction as well.
Durability − The database should be durable enough to hold all its latest updates even if
the system fails or restarts. If a transaction updates a chunk of data in a database and
commits, then the database will hold the modified data. If a transaction commits but the
system fails before the data could be written on to the disk, then that data will be updated
once the system springs back into action.
Isolation − In a database system where more than one transaction is being executed
simultaneously and in parallel, the property of isolation states that all the transactions will
be carried out and executed as if it is the only transaction in the system. No transaction
will affect the existence of any other transaction.
Result equivalence
View equivalence
Conflict equivalence
Result Equivalence
If two schedules produce the same result after execution, they are said to be result equivalent.
They may yield the same result for some value and different results for another set of values.
That's why this equivalence is not generally considered significant.
View Equivalence
Two schedules would be view equivalence if the transactions in both the schedules perform
similar actions in a similar manner.
For example −
If T reads the initial data in S1, then it also reads the initial data in S2.
If T reads the value written by J in S1, then it also reads the value written by J in S2.
If T performs the final write on the data value in S1, then it also performs the final write
on the data value in S2.
Conflict Equivalence
Two schedules would be conflicting if they have the following properties −
Both belong to separate transactions.
Both accesses the same data item.
At least one of them is "write" operation.
Two schedules having multiple transactions with conflicting operations are said to be conflict
equivalent if and only if −
Both the schedules contain the same set of Transactions.
The order of conflicting pairs of operation is maintained in both the schedules.
Note − View equivalent schedules are view serializable and conflict equivalent schedules are
conflict serializable. All conflict serializable schedules are view serializable too.
States of Transactions
Active − In this state, the transaction is being executed. This is the initial state of every
transaction.
Partially Committed − When a transaction executes its final operation, it is said to be in
a partially committed state.
Failed − A transaction is said to be in a failed state if any of the checks made by the
database recovery system fails. A failed transaction can no longer proceed further.
Aborted − If any of the checks fails and the transaction has reached a failed state, then
the recovery manager rolls back all its write operations on the database to bring the
database back to its original state where it was prior to the execution of the transaction.
Transactions in this state are called aborted. The database recovery module can select one
of the two operations after a transaction aborts −
o Re-start the transaction
o Kill the transaction
Committed − If a transaction executes all its operations successfully, it is said to be
committed. All its effects are now permanently established on the database system.
8a. There are different fields where a database management system is utilized. List the
twelve (12) applications which utilize the information based on administration framework
(12 marks)
DBMS APPLICATIONS
There are different fields where a database management system is utilized. Following are a few
applications which utilize the information base administration framework –
In the rail route reservation framework, the information base is needed to store the record
or information of ticket appointments, status about train’s appearance, and flight.
Additionally, if trains get late, individuals become acquainted with it through the
information base update.
3. Banking –
Database the executive’s framework is utilized to store the exchange data of the client in
the information base.
4. Education Sector –
Presently, assessments are led online by numerous schools and colleges. They deal with all
assessment information through the data set administration framework (DBMS). In spite of
that understudy’s enlistments subtleties, grades, courses, expense, participation, results, and
so forth all the data is put away in the information base.
7. Broadcast communications –
Without DBMS any media transmission organization can’t think. The Database the
executive’s framework is fundamental for these organizations to store the call subtleties
and month to month postpaid bills in the information base.
8. Account –
The information base administration framework is utilized for putting away data about
deals, holding and acquisition of monetary instruments, for example, stocks and bonds in a
data set.
9. Online Shopping –
These days, web-based shopping has become a major pattern. Nobody needs to visit the
shop and burn through their time. Everybody needs to shop through web based shopping
sites, (for example, Amazon, Flipkart, Snapdeal) from home. So all the items are sold and
added uniquely with the assistance of the information base administration framework
(DBMS). Receipt charges, installments, buy data these are finished with the assistance of
DBMS.
11. Manufacturing –
Manufacturing organizations make various kinds of items and deal them consistently. To
keep the data about their items like bills, acquisition of the item, amount, inventory
network the executives, information base administration framework (DBMS) is utilized.