Unit-1 RDBMS
Unit-1 RDBMS
• It’s one of IBM’s first types of Database Models for information management. The data is
organized in a tree-like structure in a Hierarchical Database Model.
• Nowadays, these types of Database models are uncommon. It has nodes for records and
branches for fields. A hierarchical Database is exemplified by the Windows registry in
Windows XP whose configuration options are saved as node-based tree structures.
• The diagram below depicts a generalized Hierarchical Database Model (data represented or
stored in the root node, parent node, and child node).
Advantages
• The network model is conceptually simple to implement.
• The network model can better represent data redundancy than the hierarchical Model.
• The network model can handle one-to-many and many-to-many relationships, which is
extremely useful in simulating real-world scenarios such as the Network model for a Finance
Department, Restaurant Chain workflow, etc.
• The network model is better than the hierarchical Model at isolating programs from complex
physical storage details. The network model allows each record to have multiple parent and
child records, forming a generalized graph structure, whereas the hierarchical database model
structures data as a tree of records with each record having one parent record and many
children.
Drawbacks
• Because all records are maintained using pointers, the Database structure becomes extremely
complicated.
• Any record’s insertion, deletion, and updating operations necessitate numerous pointer
adjustments.
• Changing the Database’s structure is extremely difficult.
Object-Oriented Database Model
In object-oriented programming, an Object Database is a system in which data is represented as
objects. Relational Databases, which are table-oriented, are not the same as object-oriented
Databases. The Object-Oriented Data Model is one of the types of database models that is based on
the widely used concept of object-oriented programming languages.
Polymorphism, inheritance, and overloading are all terms that come to mind when thinking about
inheritance. Some of the key concepts of object-oriented programming that have been applied to Data
Modeling include object identity, encapsulation, and information hiding with methods to provide an
interface to objects. In addition to structured and collection types, the object-oriented data model
supports a data-rich type system. Object-Oriented models, including general object databases with no
additional spatial functionality, are the best databases for spatial data, especially vector data.
The difference between Relational and object-oriented types of Database Models is illustrated in the
diagram below.
Types of
Database Models: Relational vs Object oriented
An Object-Oriented Model is illustrated in the diagram below.
Types
of Database Models: Object oriented Database Model Example
Advantages
• Object Databases can store a variety of data types, whereas Relational Databases store only
one type of data. Object-oriented Databases, unlike traditional Databases such as hierarchical,
network, and Relational Databases, can handle a variety of data types, including pictures,
voice, video, text, and numbers.
• You can reuse code, Model real-world scenarios, and improve reliability and flexibility with
object-oriented Databases.
• Because most of the tasks within the system are encapsulated, they can be reused and
incorporated into new tasks, object-oriented Databases have lower maintenance costs than
other Models.
Drawbacks
• An OODBMS lacks a theoretical foundation because there is no universally defined data
Model.
• OODBMS usage is still limited when compared to RDBMS usage.
• There is a lack of security support in OODBMSs that do not include adequate security
mechanisms.
• The system is more complex than conventional Database management systems.
Object-Relational Database Model
This hybrid Database Model is one of the types of Database Models that combines the Relational
Model’s simplicity with some of the Object-Oriented Database models’ advanced functionality. It
allows designers to incorporate objects into the common table structure.
SQL3, vendor languages, ODBC, JDBC, and proprietary call interfaces are all extensions of the
Relational Model’s languages and interfaces.
Entity Relationship Database Models
Entity Relationship Database Model is one of the types of Database models that is similar to the
network model, it captures relationships between real-world entities, but it isn’t as closely linked to
the Database’s physical structure. It’s more commonly used to conceptually design a Database.
The people, places, and things about which data points are stored are referred to as entities, and each
of them has specific attributes that make up their domain. The cardinality of entities, or the
relationships between them, is also mapped.
Types
of Database Models: Entity Relationship Database Model
The star schema is a common ER diagram that connects multiple dimensional tables through a central
fact table.
What is a Database Schema?
A database schema is a blueprint that represents the tables and relations of a data set.
Objectives of Normalization
Normalization reduces data redundancy there by reduces the amount of space used
by database and ensures that data is stored efficiently.
It divides large tables into many smaller tables and makes a relation between
them.
Normal Form is a process that evaluates each relation against defined rules and criteria.
It removes multi-valued primary keys, joins, functional dependencies etc., to improve
the relational table integrity and efficiency.
It plays a vital role to find the difference between good and bad database
design.
It typically exists between the primary key and non-key attribute within a table.
For any relation R, attribute Y is functionally dependent on attribute X (usually the PK), if for
every valid instance of X, that value of X uniquely determines the value of Y. This relationship
is indicated by the representation below :
X→Y
The left side of FD is known as a determinant, the right side of the production
is known as a dependent.
For example:
employee table because if we know the Emp_Id, we can tell that employee
name associated with it.
Functional dependency can be written as:
Emp_Id → Emp_Name
In Multivalued FD, entities of the dependent set are not dependent on each other.
In an Emp table empname and salary attributes both depend on empId for identification.
But both are independent to each other.
Given a relation schema, we need to decide whether it is a good design or whether we need to
decompose it into smaller relations. Such a decision must be guided by an understanding of
what problems, if any, arise from the current schema. To provide such guidance, several normal
forms have been proposed. If a relation schema is in one of these normal forms, we know that
certain kinds of problems cannot arise.
First Normal Form is defined in the definition of relations (tables) itself. This rule
defines that all the attributes in a relation must have atomic domains.
In the first normal form, only single values are permitted at the intersection of
each row and column; hence, there are no repeating groups.
Before we learn about the second normal form, we need to understand the following −
If the relation has a composite Prime Key, then each non-key attribute must be fully
dependent on the entire PK and not on a subset of the PK.
A relation is in 2NF if it has No Partial Dependency.
We see here in Student_Project relation that the prime key attributes are Stu_ID and Proj_ID.
According to the rule, non-key attributes, i.e. Stu_Name and Proj_Name must be dependent
upon both and not on any of the prime key attribute individually. But we find that Stu_Name
can be identified by Stu_ID and Proj_Name can be identified by Proj_ID independently. This
is called partial dependency, which is not allowed in Second Normal Form.
Third Normal Form (3NF):
To be in third normal form, the relation must be in second normal form. Also
- all transitive dependencies must be removed; a non-key attribute may not be functionally
dependent on another non-key attribute.
For any non-trivial functional dependency, X → A, then either –
X is a superkey or,
A is prime attribute.
Transitive dependency – If A->B and B->C are two FDs then A->C is called
transitive dependency.
We find that in the above Student_detail relation, Stu_ID is the key and only prime key
attribute. We find that City can be identified by Stu_ID as well as Zip itself. Neither Zip is a
superkey nor is City a prime attribute. Additionally, Stu_ID → Zip → City, so there exists
transitive dependency.
To bring this relation into third normal form, we break the relation into two relations as follows –
Boyce-Codd Normal Form (BCNF):
Boyce-Codd Normal Form (BCNF) is an extension of Third Normal Form on strict terms.
In the above example, Stu_ID is the super-key in the relation Student_Detail and Zip is
the super-key in the relation ZipCodes. So,
Zip → City
Example
Jhansi K.Das C
Subbu R.Prasad C
The above relation is not in BCNF, because in the FD (teacher->subject), teacher is not a
key.
R1
Teacher Subject
P.Naresh database
K.DAS C
R.Prasad C
R2
Student Teacher
Jhansi P.Naresh
Jhansi K.Das
Subbu P.Naresh
Subbu R.Prasad
All the anomalies which were present in R, now removed in the above two relations.
DECOMPOSITIONS
A decomposition of a relation schema R consists of replacing the relation schema by two (or
more) relation schemas that each contain a subset of the attributes of R and together include
all attributes in R.
When a relation in the relational model is not appropriate normal form then the decomposition
of a relation is required. In a database, breaking down the table into multiple tables termed as
decomposition.
The attributes in R will appear in at least one relation schema Ri in the decomposition, i.e., no
attribute is lost. This is called the Attribute Preservation condition of decomposition.
The relation is said to be lossless decomposition if natural joins of all the decomposition
give the original relation.
Decomposition is lossless if
1. The union of attributes of both the sub relations R1 and R2 must contain all
the attributes of original relation R.
R1 R2=R
2. The intersection of attributes of both the sub relations R1 and R2 must not be
null, i.e., there should be some attributes that are present in both R1 and R2.
R1∩R2≠∅
R1 ∩ R2 = Super key of R1 or R2
Let’s see an example of a lossless join decomposition. Suppose we have the
following relation EmployeeProjectDetail as:
<Employee Project Detail>
<Employee Project>
<Project Detail>
Project_ID Project_Name
P03 Project103
P01 Project101
P04 Project104
P02 Project102
As we can see all the attributes of Employee Project and Project Detail are in
Employee Project Project Detail relation and it is the same as the original
relation. So the first condition holds.
<EmployeeProject ∩ ProjectDetail>
Project_ID
P03
P01
P04
P02
As we can see this is not null, so the the second condition holds as well. Also the
EmployeeProject ∩ ProjectDetail = Project_Id. This is the super key of the
ProjectDetail relation, so the third condition holds as well.
Now, since all three conditions hold for our decomposition, this is a lossless
join decomposition.