0% found this document useful (0 votes)
6 views

Dbmsconcepts Intro

Uploaded by

Anand Rohit
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Dbmsconcepts Intro

Uploaded by

Anand Rohit
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 50

DBMS CONCEPTS

Introduction to Database Systems


 Data : Known Facts that can be recorded and have an implicit

meaning

 Database: A Database is an organized collection of related data

stored on disk and can be accessible by many concurrent users

 DBMS : A set of programs that manage any number of databases

 Database System:

The DBMS Software together with the data itself. Sometimes, the

Applications are also included


Introduction to Database Systems
A DBMS is responsible for :
 accessing data
 Inserting , updating and deleting data
 security, backup, recovery
 Integrity , availability, performance
Managing Data
There are two methods to manage data:
1. File Based Approach : An approach that
utilizes a collection of application programs
which performs services to end-
users(eg.Reports) . Each program defines and
manages its own data
2. Database Approach : An approach that data
is collected and manipulated using specific
software called Database Management
System, and many programs share this data
File Based Approach
DBMS vs Flat Files
 Query Ability
 Redundancy Control
 Access control
 Option to store Persistent Objects
 Backup and Migrate
 Multiple User Interfaces
 Integrity Constraints
 Relationship among Data
 Flexibility
 Application Development Time is reduced
Database Schema
Data Independence
Types of Database Schema
A database schema can be divided broadly into
two categories −
Physical Database Schema − This schema
pertains to the actual storage of data and its
form of storage like files, indices, etc. It defines
how the data will be stored in a secondary
storage.
Logical Database Schema − This schema defines
all the logical constraints that need to be applied
on the data stored. It defines tables, views, and
integrity constraints.
DBMS Architecture
 The design of a DBMS depends on its architecture

 Single Tier and Multi-tier

 Single Tier : The DBMS is the only entity where the


user directly sits on the same system and uses it .
It is called Single tier Architecture . Database
Designers and Programmers prefer this
 Ex : MS-ACCESS
General DBMS Architecture
Client/Server Architecture
Client/Server Architecture
 In this architecture , users access the Database
Server through a client application such as sqlplus,
sql developer etc.,

 Direct Communication between the Data Source


and the Client Application

 User Interface Program and Application Programs


runs on Client Side through ODBC (Open Database
Connectivity)
Adv & Disadv of Client/Server
 Advantages :
 Easy to maintain
 Faster Communication

Disadvantages :
 Cost- Ineffective
 Performance is less for higher number of
users
3- Tier Architecture
3-Tier Architecture
 This tier is used for Business Applications like web based

 It Consists of Client Layer, Applications Layer and Data

Layer

 The Client Layer (Presentation Layer) consists of User

Interface (UI) and used for design purpose . The End users

operate on this tier

 The Application Layer Hides the Physical storage structures

from the End user and describes entities, data types,

relationships and Constraints


3-Tier Architecture
 The Data Layer consists of Internal View of Data and
its representation method like Storage Allocation and
Access Paths etc.,
 File Organization, Access Paths like Indexes, data
compression techniques, encryption methods and
record placement
 The information is received and stored in a file system
or database . This information is processed in the
Logical Tier and returned back to the Presentation
Introduction to Data Modeling
 Data Models represent the logical or
conceptual representation of data
 Data Models are helpful in data abstraction
 Data Models are useful in processing and
storing data
 The Predominantly used data models are :
1. Hierarchical Model
2. Network Model
3. Relational Model
Hierarchical Model(Inverted Tree)
Hierarchical Model
 Each entity can have a single parent but several
children
 At the top of hierarchy there is an entity called
Root.
 Data is organized like an organization chart

 Each node represents an entity and its


subordinate entity represents the next level of
hierarchical tree
Hierarchical Model
Each entity is equivalent of a table. The record
is represented by row and attribute by column
 The relationship depicted is 1:N mapping

Drawbacks:
It cannot represent all the relationships
between data
 It is very difficult to modify
Network Model

Entities are organized in a graph .


Some entities can be accessed via various
paths
i.e., M:N relationships
It is slow, complex and more difficult to
maintain
Relational Model
 Data are organized in the two dimensional
tables called relations : Eg: Oracle,MySQL,
SQLServer
E-R Model
 Entity – Relationship Model defines the
conceptual view of a database
 E-R model defines the real world objects as
Entities and their association as Relationship
 The attributes represent the properties of
the entities
E- R Model
 The student is an entity and its attributes are

Name, Roll_No , BirthDate , PhoneNo etc.,


Normalization
Normalization is the process of removing
redundancies , anomalies etc.,
First Normal Form : Every attribute of a table
must be atomic i.e . Non-divisible
After First Normal Form
First Normal Form
Second Normal Form
 It states that Every Non-Prime Attribute Should
be fully functionally dependent on all
prime attributes
 Before Second Normal Form: Stu_Name
depends on Stu_ID only and not Proj_ID and
hence it is partially dependent
After Second Normal Form
 The above relation Student_Project is
divided into two tables : Student and
Project
Third Normal Form
 It should hold Second Normal Form

It Should not be transitively dependent


After Third Normal Form
SQL BASIC OPERATIONS
 DDL Commands – Data Definition Language

DML Commands – Data Manipulation Language

 DRL Commands - Data Retrieval Language

DCL Commands – Data Control Language

TCL Commands - Transaction Control Language


DDL Commands
 These are Auto Commit Commands
 The datatypes can be char, varchar ,

varchar2,number ,long, date


 create , alter , drop, truncate
 create - To create a table
 create table stud(sid number, sname
varchar2(20));
 desc stud;
DDL Commands
 alter - To alter a Table . This command is used

to add , drop, rename and modify columns

 alter table stud add(saddr char(10), smobno


number);

 alter table stud rename column saddr to sadd;

 alter table stud drop column sadd;

 alter table stud modify (sadd varchar2(20));


DDL Commands
 drop table stud; Drops the entire table

 truncate - truncates the table . The contents


are deleted maintaining its structure as it is
 truncate table stud;
DML Commands
 DML Commands are : insert, update,delete. These
commands are to be committed
insert – inserts records into database

insert into stud values(&sid,’&sname’);

insert into stud sid(543) ; commit;

update - updates the database records selectively or as a


whole
 update stud set sname=‘thiagu’ where sid=543;

commit;
DML Commands
 delete – deletes the records selected rows or
as a whole
delete from table where sid=543;
delete from stud; the whole table contents are
deleted
commit;
DRL , TCL
 select statement is DRL
 select sid,sname from stud;
 select * from stud;
 select * from stud where no>453;
TCL
 commit,rollback ,savepoint
 whenever a transaction is committed it
is written into the database
 rollback; This is equivalent to undo
SavePoint: Temporarily Saving the data
till previous commit
DCL – data control language
 grant and revoke
 grant – grants permissions, privileges,roles
and profiles to users
 grant connect,resource to user1;
 revoke – takes back the
permissions,privileges,roles and profiles from
the users
 revoke connect,resource from user1;
Constraints
 To give conditions according to our needs
 There are three types of constraints:
 Domain - not null, check, default
 Entity - primary key , unique key
 Referential - foreign key

not null – This constraint prohibits the database to


have null values
unique constraint – This constraint does not allow
repeated values in the same column or group of
columns
Constraints
 primary key – combination of unique and not null
constraints
 foreign key – A parent table references a child table

 check – This constraint checks the value of some


specific column
default – This constraint assigns default values to the
columns
Constraints
 SQL> create table tt(tno number constraint ctt not
null,tname varchar(10));
Table created
SQL> alter table tt modify(tname constraint tt_cc not
null);
Table altered.
SQL> create table nn(nno number constraint nncc
PRIMARY KEY,nname varchar(10));
Table created.
SQL> create table ss(sno number,sname varchar(10));
Table created.
SQL> alter table ss modify(PRIMARY KEY(sno));
Table altered.
Constraints
 SQL> alter table ss add(constraint sscc check(sno<100));

Table altered

 SQL> alter table ss add(cname varchar(10) default('B.D.S'));

Table altered.

 SQL> alter table ss add(studid number constraint stss

unique);

Table altered.
Constraints
 SQL> create table pt(name varchar(10),id number
constraint pk PRIMARY KEY,sal number);

Table created.
SQL> create table ct(sname varchar(10),id number

constraint fk references pt(id));

Table created.

You might also like