RDBMS
RDBMS
RDBMS
RDBMS
Topics (Module 1)
• Introduction to SQL
To explain the basic DDL ,DML commands, the concept of sub queries
(independent and correlated), views, set operations (union, intersect, minus)
(Module 3)
• Subqueries
Database Fundamentals and RDBMS Concepts
MODULE 1
What is RDBMS?
Shiv 40 $25.000
Database management System
What is Database ?
A Database is a collection of related data
What is DBMS?
Application where the following operations can be performed on
data:
• Storing
• Modifying
• Retrieving
Traditionally the data was stored in form of File System.
• In traditional
approach, information
is stored in flat files
which are maintained
by the file system
under the operating
system’s control.
• Application programs
go through the file
system in order to
access these flat files
How data is stored in flat files
• Data Redundancy
• Data Isolation
• Atomicity problem
• Program/Data Dependence
• Data Security
Data Redundancy and Inconsistency
Manager
Requirement
Application
Programs
File System
(Programs Database
Written in C (Data Structure (Information Storage
Pascal etc.) File Handling) in Files Format)
Data Isolation and Integrity Problems
#include <stdio.h>
01 Reserve-rec.
Main()
03 saving
{
05 accno PIC A(2)
-----
--------
}
New Document
Atomicity Problems
Bank
Data Transmission
Concurrent-access anomalies
Security Problems
Employee
Information
Difference between DBMS and RDBMS
DBMS RDBMS
DBMS applications store data as file. RDBMS applications store data in a tabular form.
DBMS does not apply any security with regards to data RDBMS defines the integrity constraint for the purpose
manipulation of ACID (Atomicity, Consistency, Isolation and Durability)
property.
DBMS does not support distributed database. RDBMS supports distributed database.
Data redundancy is common in DBMS. Keys and indexes are used to avoid redundancy.
Difference between DBMS and RDBMS
DBMS RDBMS
DBMS is meant to be for small organization and deal RDBMS is designed to handle large amount of data. it
with small data. it supports single user supports multiple users
In dbms relationship between two tables or files are In Rdbms relationship between two tables or files can
maintained programmatically be specified at the time of table creation.
Transaction management is not possible ,insecure. Efficient Transaction management and secure.
Examples of DBMS are file systems, xml etc. Example of RDBMS are mysql, postgre, sql server,
oracle etc.
View of DATA
Logical Data
Independent
Physical Data
Independent
group of users
Conceptual schema
referential integrity
Internal schema
Physical storage (the number bytes required , and the data storage
location)
E.F CODD’S 12 RULES OF RELATIONAL
DATABASE
OVERVIEW OF CODD’s RULE
• All data are uniquely identified and accessible via this identity.
• Most RDBMS do not make the definition of the primary key mandatory
• View Definition
.
Rule 6: VIEW UPDATING RULE
This rule states that insert, update, and delete operations should be supported for
any retrievable set rather than just for a single row in a single table.
It also perform the operation on multiple row simultaneously .
There must be delete, updating and insertion at the each level of operation. Set
operation like union, all union , insertion and minus should also supported.
EXAMPLE:
Suppose if we need to change ID then it will reflect everywhere automatically.
EXAMPLE
• Create table:
SQL>CREATE TABLE STUDENT_DATA
{ NAME ROLL_NO CLASS
NAME VARCHAR 2(20),
ROLL_NO VARCHAR 2(10 NAME ROLL_NO CLASS
),
KIRAN 4566 BCA
CLASS VARCHAR 2(20);
};
RAHUL 3455 BCA
INSERT ION:
SQL>INSERT INTO STUDENT_DATA(‘&NAME’,&ROLL_NO,’&CLASS’);
SQL>ENTER VALUE FOR NAME:KIRAN
SQL>ENTER VALUE FOR ROLL_NO:4556
SQL>ENTER VALUE FOR CLASS:BCA
SQL>/
RULE 8 :LOGICAL DATA INDEPENDENCE RULE
• What is independence?
The ability to modify schema definition in on level without affecting schema definition in the next higher
level is called data independence
• The ability to change the logical (conceptual) schema without changing the External schema (User View)
is called logical data independence.
• EXAMPLE:
The addition or removal of new entities, attributes, or relationships to the conceptual schema should be
possible without having to change existing external schemas or having to rewrite existing application
programs.
RULE 9:PHYSICAL DATA INDEPENDENCE
• The ability to change the physical schema without changing the logical schema is called physical
data independence.
• This is saying that users shouldn’t be concerned about how the data is stored or how it’s accessed.
In fact, users of the data need only be able to get the basic definition of the data they need.
• EXAMPLE:
A change to the internal schema, such as using different file organization or storage structures,
storage devices, or indexing strategy, should be possible without having to change the conceptual
or external schemas.
RULE 10 : INTEGRITY INDEPENDENCE RULE
• Data integrity refers to maintaining assuring the accuracy and
consistency of data over its entire life cycle.
• Distribution independence implies that user should not have to be aware of whether a database is
• Application program and adhoc request are not affected by the change in distribution of physical
data. Application program will work even if the programs and data are moved on different site
• The RDBMS may spread across the more one system or several networks
RULE 12 : NON-SUBVERSION RULE
• There should be no way to modify to database structure other then through the
multiple row data base language(SQL).
Example:
A relational system has a low-level (single-record-at-a-time) language, that low level cannot be used
to subvert or bypass the integrity Rules and constraints expressed in the higher level relational
language (multiple-records-at-a-time).”
Question 1
According to Codd rule, how one should be able to access information about data structures like
databases, tables etc.
• b. Should be directly accessible via same query language used for data
• The table is said to first normal form if the data in each column is
automic (no mutiple value or comma seperated)
• No repeating column groups
unnormalized and normalized
Course Student
Database Ajay,
Raj,
Vijay
Math Kumar,
Kiran
Course Student
Database Ajay
Database Raj
Database Vijay
Math Kumar
Math Kiran
2NF (Second Normalization Form)
1. it should be in 1NF
2. no redundant data
3. create a relationship using foreign key
1NF
Customerid custname age address phone ordered orderdate productid product price qty total
Customer
Customerid custname age address phone
Orders
Customerid orderid orderdate product price qty total
2. does not contain any column which is not fully depend on primary
key.
3NF
Customer
Customerid custname age address phone
Orders
Customerid orderid orderdate product price qty total
• A primary key is an attribute which has its own unique identity. A primary key never
repeat itself. The primary key should be chosen such that its attributes are never or
rarely changed.
Eg: Branch_id
• Candidate key:
• The keys which are eligible to be a primary key those set of keys are called as
candidate keys. It can be a attribute or set of attributes that uniquely identifies
a record. So a table can have multiple candidate key but each table can have
maximum one primary key.
• Eg: Branch_code
Foreign key:
• Foreign key is used to generate the relationship between the tables.
Foreign key is a field in database table that is primary key in another
table.
• Alternate key:
• Alternate keys are candidate keys that are not selected as primary key.
Alternate key can also work as a primary key. Alternate key is also called
“Secondary Key”.
• Eg: Branch_code
Composite key:
An ERD is a data modeling technique that can help define business processes
and be used as the foundation for a relational database.
COMPONENTS OF ER DIAGRAM
• Entity
• Weak entity
• Weak entity relationship
• Attributes
• Relationships
ENTITY
• Simple Attribute
• Compound Attribute
• Derived Attribute
• Multi-valued Attribute
Simple Attribute
Derived attributes are the attributes that do not exist in the physical
database, but their values are derived from other attributes present in the
database.
For example, age can be derived from data_of_birth.
Multi-valued Attribute
When more than one instance of entity is associated with the relationship, it
is marked as 'N:1'.
The following image reflects that more than one instance of an entity on the
left and only one instance of an entity on the right can be associated with
the relationship.
It depicts many-to-one relationship.
MANY TO MANY RELATIONSHIP
The following image reflects that more than one instance of an entity on
the left and more than one instance of an entity on the right can be
associated with the relationship.
It depicts many-to-many relationship.
ER Diagram of bank database scheme Addr
Branch_
no
1 BRANCH N BANK_BRAN
BANK CH
ES
1 1
Code Name Addr ACCTS LOANS
Ssn N Name N
CUSTOME
Phone Addr
R
Why DBMS?
• Database systems are basically developed for dealing with large amount of
data.
• There are two main things in DBMS: Storing and Retrieval of Data
• Storage:
• According to the principles of database systems, the data is stored in
such a way that it acquires lot less space as the redundant data has been
removed before storage.
• Retrieval:
• Along with storing the data in an optimized and systematic manner, it is
also important that we retrieve the data quickly when needed. Database
systems ensure that the data is retrieved as quickly as possible.
DBMS Database Models
• A Database model defines the logical design and structure of a database and defines how
data will be stored, accessed and updated in a database management system. While the
Relational Model is the most widely used database model, there are other models too:
• Hierarchical Model
• Network Model
• Entity-relationship Model
• Relational Model
Hierarchical Model