You are on page 1of 14

DBMS FILE

Different Between Data And Information :

• Introduction of the Database and the DBMS: -


Data base:-
Database is a collection of inter related data. It is
organized to store, manage and access information.

Management System:-
It is the set of programs that provide a lot of
functionalities to store, manage, manipulate, and access
information from a database in an efficient way.
DATABASE AND MANAGEMENT SYSTEM :-
• Data base and management is a collection of
interrelated data and set of programs to access those
data to understand it in a better way.
FOR EG: -
• MY SQL
• SY BASE
• ORACLE
• MS SQL Server
• MS ACCESS
Role Of DBMS:-
• Configuring authentication and
authorization. Easily configure user
accounts, define access policies, modify
restrictions, and access scopes. These
operations allow administrators to limit
access to underlying data, control user
actions, and manage users in databases
• Providing data backups and
snapshots. DBMS can simplify the backup
process of databases by providing a simpler
and straightforward interface to manage
backups and snapshots.
• Performance tuning. DBMS can monitor the
performance of databases using integrated
tools and enable users to tune databases by
creating optimized indexes.
• Data recovery. In a recovery operation, DBMS
provides a recovery platform with the
necessary tools to fully or partially restore
databases to their previous state-effortlessly.
• Advantages of DBMS :
• It reduce data redundancy
• It control inconsistency
• It can shared by multiple user.
• It provide data security
• It provide data integrity
• It provides centralised control facilites.

THE RELATIONAL MODEL


Introduction
The relational model in DBMS is an abstract model used
to organize and manage the data stored in a database. It
stores data in two-dimensional inter-related tables, also
known as relations in which each row represents an
entity and each column represents the properties of the
entity.
What is the Relational Model ?
The relational model for database management is an
approach to logically represent and manage the data
stored in a database. In this model, the data is organized
into a collection of two-dimensional inter-related tables,
also known as relations. Each relation is a collection of
columns and rows, where the column represents the
attributes of an entity and the rows (or tuples) represents
the records.
As we can notice from the above relation:
• Any given row of the relation indicates a student i.e.,
the row of the table describes a real-world entity.
• The columns of the table indicate the attributes
related to the entity. In this case, the roll number,
CGPA, and the name of the student.

THE E-R MODEL


Introduction
An Entity–relationship model (ER model) describes the
structure of a database with the help of a diagram,
which is known as Entity Relationship Diagram (ER
Diagram). An ER model is a design or blueprint of a
database that can later be implemented as a database.
What is E-R Diagram ?
An ER diagram shows the relationship among entity
sets. An entity set is a group of similar entities and
these entities can have attributes. In terms of DBMS,
an entity is a table or attribute of a table in database,
so by showing relationship among tables and their
attributes, ER diagram shows the complete logical
structure of a database.

There are three components of E-R diagram :


• Entity
• Attribute
• Relationship
1. Entity : It is a real world object that related to other
object. This is one which is meaningful for system and
information about which need to be stored.
2. Attribute : the property of entity is called attribute.
Attribute are the information about the entity which we
want to store.
Type of attribute :
(i)Simple attribute: An attribute that cannot be further
subdivided into components is a simple attribute.
(ii)Composite attribute: An attribute that can be split into
components is a composite attribute.
(iii)Single-valued attribute :
The attribute which takes up only a single value for each
entity instance is a single-valued attribute.
(iv)Multi-valued attribute :
The attribute which takes up more than a single value for
each entity instance is a multi-valued attribute.
• What is relationship?
Relationships in DBMS are actually created between
entities.Any association between two entities is known as
a relationship between those two entities.

THE RELATIONAL DATABASE MODEL


• A Logical View of Data
What Is Logical View Of Data In DBMS?
In an enterprise, a logical view of data is a data model.
There are logical data objects in a logical data object
model. In an organization, a logical data object describes
a logical entity, such as a customer or an order, which is a
logical entity. attributes and keys, and describes the
relationships between them.
What Is A Logical View Of Data?
An enterprise’s logical view of data is a data model that
can be used to create a single view of data. To do this,
define a logical data object model. An Order ID attribute
and a Customer ID attribute are defined in a logical data
model, for example.
• Keys
What are the keys in DBMS?
A key refers to an attribute/a set of attributes that help
us identify a row (or tuple) uniquely in a table (or
relation). A key is also used when we want to establish
relationships between the different columns and tables
of a relational database

The different types of keys in DBMS are −


• Candidate Key - The candidate keys in a table are
defined as the set of keys that is minimal and can
uniquely identify any data row in the table.
• Primary Key - The primary key is selected from one
of the candidate keys and becomes the identifying key of
a table. It can uniquely identify any data row of the table.
• Super Key - Super Key is the superset of primary key.
The super key contains a set of attributes, including the
primary key, which can uniquely identify any data row in
the table.
• Composite Key - If any single attribute of a table is
not capable of being the key i.e it cannot identify a row
uniquely, then we combine two or more attributes to
form a key. This is known as a composite key.
• Foreign Key - A foreign key is an attribute value in a
table that acts as the primary key in another table.
Hence, the foreign key is useful in linking together two
tables. Data should be entered in the foreign key column
with great care, as wrongly entered data can invalidate
the relationship between the two tables.
The Data Dictionary
• A Data Dictionary Definition
A Data Dictionary is a collection of names, definitions,
and attributes about data elements that are being used or
captured in a database, information system, or part of a
research project. It describes the meanings and purposes
of data elements within the context of a project, and
provides guidance on interpretation, accepted meanings
and representation.

• Use a Data Dictionary?


Data Dictionaries are useful for a number of reasons. In
short, they:
• Assist in avoiding data inconsistencies across a project
• Help define conventions that are to be used across a
project
• Provide consistency in the collection and use of data
across multiple members of a research team
• Make data easier to analyze
• Enforce the use of Data Standards

Relationship within the relational database

what is relationship in DBMS?


A relationship, in the context of databases, is a
situation that exists between two relationaldatabase
tables when one table has a foreign key that
references the primary key of the other table.
Relationships allow relational databases to split and
store data in different tables, while linking disparate
data items.
Different types of relationship in Database?
(1) One to One: One entity is associated with
another entity. In the absence of such a rule, you
can usually combine both tables into one table
without breaking any normalization rules.
(2) One to Many: One entity is associated with
many other entities. The primary key table contains
only one record that relates to none, one, or many
records in the related table.
(3) Many to Many: Many entities are associated
with many other entities. Each record in both tables
can relate to any number of records (or no records)
in the other table.

THE NEED OF NORMALIZATION


Normalization is a technique for designing relational
database tables in such a way that ensure minimization
of duplicate information and use of database is always
unambiguous and as intended.
The benefits of Normalization includes:
• Reduce data redundancies.
• Reduce required storage space.
• Prevent the need to restructure existing tables to
accommodate new data.
• Increased speed and flexibility of queries, sorts, and
summaries.
• Help eliminate data anomalies.
• No information is lost in normalization.
• Simplify maintenance and retrieval of information.
THE NORMALIZATION PROCESS

Normalization is a step wise process, there are a series


of guidelines for ensuring that databases are
normalized. These are referred to as normal forms and
are numbered from one (the lowest form of
normalization, referred to as first normal form or INF)
through five (fifth normal form or 5NF).
In practical applications, you will often see INF, 2NF, and
3NF and in this section we will only discuss these three
normal forms.
FIRST NORMAL FORM (INF)
The first normal form (or INF) requires that the values in
each column of a table are atomic. By atomic we mean
that there are no sets of values within a column.
Now take an example of Department Table which is
storing information about each department of an
organization as below:
Department: (dept_id, dept_name, contact no)

Here we can see from Department table that for one


department more than one contact numbers are being
stored that means column contact_no is not atomic as
it is having set Of values instead of one value.
Thus table Department is not in INF. We will bring the
table in INF by splitting the table in two tables as
bellow:
Department: (dept_id, dept_name)

Department_Contact:(dept_id, contact no)


Table: Department
dept _ id dept _ name
DEP - 01 Sales
DEP - 02 Accounting
DEI) 03
Marketing
Table:
Dcpartment_Contact

dept_id contact_no
DEP-OI 011-22234561
DEP-01 011-22334567
DEP-02 011-22334568
DEP-03 011-
23345672
DEP-03 011-
23345673

Now both tables are in INF.


• SECOND NORMAL FORM (2NF)
Second Normal Form (2NF) deals with relationships
between composite key columns and non-key
columns.
A table is in 2NF if:
Tables is in First Normal Form.
There is no partial dependency in the table i.e. all
non-key columns depend on the entire primary
key. It means that if a primary key is composite
then no non-key column will depend on part of
the key.
Now take an example of Table Product_Customer:
This table maintain information as below:
Pr0duct-Customer: (product_id, customer_id,
customer_name, contact_no, quantity, purchase_date).
P
rimary key of the table is composed of two attributes:
product_id and customer_id.
Primary Key: (product_id, customcr_id).

From table we can conclude that:


Table is in INF.
Non-key attributes quantity and purchase_date depend
on entire primary key (product_id, customer_id)
Non-key attributes customer_name and contact_no
does not depend on entire primary key (product_id,
customer_id), they depend on only customer_id
not on product_id, thus they have partial
dependency on primary key so the table is not in
2NF.
Now, we will convert the table into 2NF by splitting it
into two tables as below:
Product-Customer: (product_id, customer_id, quantity,
purchase_date)
Customer: (customer_id, customer_name, contact_no)

Table: Product_Customer
product_i cutomer_i quantit purchase_dat
d d y a
PRO-OI CUS-OI 2 23/04/09
PRO-02 CUS-OI 3 23/04/09
PRO-OI CUS-02 3 25/04/09
PRO-02 CUS-02 5 26/04/09
PR04)3 CUS-03 5 23/04/09
TABLE : CUSTOMER
Customer_i customer_na contact no
d me
CUS-01 Faisal 9897654.32
3
CUS-02 Sania 9894444234
CUS-03 Fahad 990876.534
5

Now both tables are in 2NF.


Third Normal Form
A table is in 3NF if:
Table is already in Second Normal Form.
All columns depend directly on the primary key,
there is no transitive dependencies.
Second condition says that if in a table one column
depends on another column, which in turn depends on
the primary key (a transitive dependency), then it will
not be in 3NF.
Let’s take an example of table Customer as below:
Customer: (customer_id. customer_name, zip_no, state,
city)
Primary key of the table is.Customer id
Table: Customer
customer_i Customer Zip_ state city
d _ name no
CUS-OI Anand 34201
0
Rajastha Jodhpur
n
CUS-02 Aruna 34201
0
Rajastha Jodhpur
n
CUS-03 Alpesh 38000
9 Gujarat Ahmedaba
d
CUS - 04 Kavita 38000
9 Gujarat Ahmedaba
d
CUS-05 Khanak 38000
9 Gujarat Ahtnedaba
d
From table customer we can conclude that:
Table is in 2NF as all non-key attributes depend on its
primary key customer_id.

Non-key attributes state and city depend on zip


and zip depend on primary key, thus they
transitively depend on primary key not directly so
the table Customer is not in 3NF.
Now we will convert table Customer into 3NF by
splitting it into two tables as below:
Customer: (customer_id. customer_name, zip_no).
Zip: (zip_no. state. city)
Table: Customer
customer customer zip no
id _ name
CUS-OI Anand 342010
CUS -02 Aruna 342010
CUS -03 Alpesh 380009
CUS -04 Kavita 380009
CUS-05 Kanak 380009
Table: Zip
zip _ state city
no
342010 Rajasthan Jodhpur
380009 Gujarat Ahmedabad

Now both tables are in 3NF.


SQL FUNDMETAL
Structured Query Language (SQL)
• Structed Query Language is a standard Database
language which is used to create, maintain and
retrieve the relational database. Following are
some interesting facts about SQL.
• SQL is case insensitive. But it is a recommended
practice to use keywords (Like, select, Update,
Create, etc) in capital letters and use users
defined things (linked table name, column
name, etc) in small letters.
• We can write comments in SQL using “_”
(double hyphen) at the beginning of any line.
• SQL is the programming language for relational
databases (explain below) like My SQL, Oracle
Sybase, SQL Server, postgre, etc. Other non-
rational databases (also called NoSQL)
databases like MongoDB, DynamoDB, etc do not
used SQL.
• Although there is an ISO standard for SQL, most
of the implementations slightly vary in syntax.
So we may encounter queries that works in SQL
Server but do not work in my SQL.
DDL (Data Definition Language):
DDL or Data Definition Language actually consists
of the SQL commands that can be used to define
the database schema. It simply deals with
descriptions of the database schema and is used to
create and modify the structure of database objects
in the database.DDL is a set of SQL commands
used to create, modify, and delete database
structures but not data. These commands are
normally not used by a general user, who should be
accessing the database via an application.
List of DDL commands:
• CREATE: This command is used to create the
database or its objects (like table, index,
function, views, store procedure, and
triggers).
• DROP: This command is used to delete
objects from the database.
• ALTER: This is used to alter the structure of
the database.
• TRUNCATE: This is used to remove all
records from a table, including all spaces
allocated for the records are removed.
• COMMENT: This is used to add comments to
the data dictionary.
• RENAME: This is used to rename an object
existing in the database.
DML(Data Manipulation Language):
The SQL commands that deals with the
manipulation of data present in the database belong
to DML or Data Manipulation Language and this
includes most of the SQL statements. It is the
component of the SQL statement that controls
access to data and to the database. Basically, DCL
statements are grouped with DML statements.
List of DML commands:
• INSERT : It is used to insert data into a table.
• UPDATE: It is used to update existing data
within a table.
• DELETE : It is used to delete records from a
database table.
• LOCK: Table control concurrency.
• CALL: Call a PL/SQL or JAVA subprogram.
• EXPLAIN PLAN: It describes the access path
to data.

You might also like