RDBMS
RDBMS
Topics
What is Database?
What is DBMS?
RDBMS Concepts
Data Model
Keys
Normalization
What is a Database?
A Database is a collection of related data organized in a way that data can
be easily accessed, managed and updated. Any piece of information can be
a data, for example name of your school. Database is actually a place
where related piece of information is stored and various operations can be
performed on it.
Address Book
Hard Disk
What is a DBMS?
A DBMS is a software that allows creation, definition and manipulation of
database. DBMS is actually a tool used to perform any kind of operation on
data in database. DBMS also provides protection and security to database.
It maintains data consistency in case of multiple users. Here are some
examples of popular dbms, MySql, Oracle, Sybase, Microsoft Access and
IBM DB2 etc.
Database Management System
User system to
extract information
from the database
DBMS
Database
RDBMS Concepts
A Relational Database management System(RDBMS) is a database
management system based on relational model introduced by E.F Codd. In
relational model, data is represented in terms of tuples(rows).
2. Table
3. Field
4. Record
RDBMS Concepts
What is Data Model?
A data model is a description of the data in a database.
Data models can be broadly classified into the following categories:
1. Object-based logical model: Focuses on describing the data, the relationship
among the data, and any constraints defined.
Attributes
Attributes
Relationship
Entities
What is Data Model
An entity:
1. Is any object, place, person, or activity about which the data is recorded.
3. In the ER model diagramming technique, entities are named and represented inside a
box.
4. For example:
What is Data Model?
A Relationship
Chen defined a relationship as “an association among entities”.
A relationship is depicted as a diamond with the name of the relationship type.
For example:
Relationship
3 types :
1. One-to-one 2. One-to-many 3. Many-to-many
What is Data Model
What is Data Model
An attribute: Is a property of a given entity.
Is depicted as ellipses, labeled with the name of the property.
The following diagram shows the various attributes of the entity, STUDENT.
Record-based logical model
A Database model defines the logical design of data. The model describes
the relationships between different parts of the data. Historically, in
database design, three models are commonly used. They are,
1. Hierarchical Model
2. Network Model
3. Relational Model
Hierarchical Model
In this model each entity has only one parent but can have several children .
At the top of hierarchy there is only one entity which is called Root.
Network Model
In the network model, entities are organized in a graph, in which some
entities can be accessed through several path
Relational Model
In this model, data is organized in two-dimesional tables called relations.
The tables or relation are related to each other.
Keys
An RDBMS identifies and locates rows by value.
The physical address is transparent to the user.
Relational systems require keys that can uniquely identify the rows of a
table.
2. Foreign
3. Candidate
4. Alternate
5. Composite
Keys
Any attribute (or set of attributes) that uniquely identifies a row in a table is
a candidate for the primary key. Such an attribute is called a candidate key.
Any attribute that is a candidate for the primary key but is not the primary
key is called the alternate key.
When the key that uniquely identifies the rows of the table is made up of
more than one attribute, it is called a composite key.
Definition of Normalization
Normalization is a method of breaking down complex table structures into
simple table structures by using certain rules. Using this method, you can
reduce redundancy in a table, and eliminate the problems of inconsistency
and disk space usage. You can also ensure that there is no loss of
information.
3. It helps in reducing the null values, which reduces the complexity of data operations.
Definition of Normalization
Some rules that should be followed to achieve a good database design are:
1. Each table should have a unique identifier.
Each table should be organized into rows, and each row should have a
primary key that distinguishes it as unique.
The Primary key is usually a single column, but sometimes more than one
column can be combined to create a single primary key. For example
consider a table which is not in First normal form
Student Table :
Student Age Subject
Adam 15 Biology, Maths
Alex 14 Maths
Stuart 17 Maths
First Normal Form
In First Normal Form, any row must not have a column in which more than
one value is saved, like separated with commas. Rather than that, we must
separate such data into multiple rows.
Adam 15 Maths
Alex 14 Maths
Stuart 17 Maths
Using the First Normal Form, data redundancy increases, as there will be
many columns with same data in multiple rows but each row as a whole will
be unique.
Functional Dependency
The normalization theory is based on the fundamental notion of functional
dependency. Given a relation (you may recall that a table is also called a
relation) R, attribute A is functionally dependent on attribute B if each value
of A in R is associated with precisely one value of B.
Primary key
Functional Dependency
In the REPORT table:
For a particular value of ROLL_NUMBER+COURSE_CODE, there is precisely one
corresponding value for MARKS.
ROLL_NUMBER
MARKS
COURSE_CODE
Functional Dependency
The other functional dependencies in the REPORT table are:
COURSE_CODE->COURSE_NAME
COURSE_CODE->T_NAME (Assuming one course is taught by only one teacher.)
T_NAME->ROOM_NUMBER (Assuming each teacher has his/her own, unshared room.)
MARKS->GRADE
ROLL_NUMBER COURSE_NAME
T_NAME
COURSE_CODE
ROOM_NUMBER
Functional Dependency
ROOM_NUMBER is dependent on T_NAME, and T_NAME is dependent on
COURSE_CODE, as shown in the following diagram.
The only non-key item is HOURS, which is dependent on the whole key,
ECODE+PROJCODE or NAME+PROJCODE.
ECODE and NAME are determinants since they are functionally dependent on each other.
As per BCNF, the determinants have to be candidate keys.
You can remove NAME and ECODE and place them in a different table.
Boyce-Codd Normal Form (BCNF)
You can remove NAME and ECODE and place them in a different table, as
shown in the following diagram
Summary
Database is a collection of related data organized in order to provide ease in
data access and management.