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

DBMS Unit 1

Introduction to DBMS
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

DBMS Unit 1

Introduction to DBMS
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Introduction of DBMS

INTRODUCTION:

A Database Management System (DBMS) is a software system that is


designed to manage and organize data in a structured manner. It allows
users to create, modify, and query a database, as well as manage the
security and access controls for that database.

Some key features of a DBMS include:

1. Data modeling: A DBMS provides tools for creating and modifying


data models, which define the structure and relationships of the data
in a database.
2. Data storage and retrieval: A DBMS is responsible for storing and
retrieving data from the database, and can provide various methods
for searching and querying the data.
3. Concurrency control: A DBMS provides mechanisms for controlling
concurrent access to the database, to ensure that multiple users can
access the data without conflicting with each other.
4. Data integrity and security: A DBMS provides tools for enforcing data
integrity and security constraints, such as constraints on the values of
data and access controls that restrict who can access the data.
5. Backup and recovery: A DBMS provides mechanisms for backing up
and recovering the data in the event of a system failure.
6. DBMS can be classified into two types: Relational Database
Management System (RDBMS) and Non-Relational Database
Management System (NoSQL or Non-SQL)
7. RDBMS: Data is organized in the form of tables and each table has a
set of rows and columns. The data is related to each other through
primary and foreign keys.
8. NoSQL: Data is organized in the form of key-value pairs, document,
graph, or column-based. These are designed to handle large-scale,
high-performance scenarios.

Database is a collection of interrelated data which helps in the efficient


retrieval, insertion, and deletion of data from the database and organizes
the data in the form of tables, views, schemas, reports, etc. For Example,
a university database organizes the data about students, faculty, admin
staff, etc. which helps in the efficient retrieval, insertion, and deletion of
data from it.
There are four types of Data Languages
1. Data Definition Language (DDL)
2. Data Manipulation Language(DML)
3. Data Control Language(DCL)
4. Transactional Control Language(TCL)

DDL is the short name for Data Definition Language, which deals with
database schemas and descriptions, of how the data should reside in the
database.
 CREATE: to create a database and its objects like (table, index,
views, store procedure, function, and triggers)
 ALTER: alters the structure of the existing database
 DROP: delete objects from the database
 TRUNCATE: remove all records from a table, including all spaces
allocated for the records are removed
 COMMENT: add comments to the data dictionary
 RENAME: rename an object

DML is the short name for Data Manipulation Language which deals with
data manipulation and includes most common SQL statements such
SELECT, INSERT, UPDATE, DELETE, etc., and it is used to store,
modify, retrieve, delete and update data in a database.
 SELECT: retrieve data from a database
 INSERT: insert data into a table
 UPDATE: updates existing data within a table
 DELETE: Delete all records from a database table
 MERGE: UPSERT operation (insert or update)
 CALL: call a PL/SQL or Java subprogram
 EXPLAIN PLAN: interpretation of the data access path
 LOCK TABLE: concurrency Control

DCL is short for Data Control Language which acts as an access


specifier to the database.(basically to grant and revoke permissions to
users in the database
 GRANT: grant permissions to the user for running DML(SELECT,
INSERT, DELETE,…) commands on the table
 REVOKE: revoke permissions to the user for running DML(SELECT,
INSERT, DELETE,…) command on the specified table

TCL is short for Transactional Control Language which acts as an


manager for all types of transactional data and all transactions.Some of
the command of TCL are
 Roll Back: Used to cancel or Undo changes made in the database
 Commit: It is used to apply or save changes in the database
 Save Point: It is used to save the data on the temporary basis in the
database

Introduction of 3-Tier Architecture in


DBMS
DBMS 3-tier Architecture
DBMS 3-tier architecture divides the complete system into three inter-
related but independent modules as shown below:

1. Physical Level: At the physical level, the information about the


location of database objects in the data store is kept. Various users of
DBMS are unaware of the locations of these objects.In simple
terms,physical level of a database describes how the data is being
stored in secondary storage devices like disks and tapes and also
gives insights on additional storage details.
2. Conceptual Level: At conceptual level, data is represented in the
form of various database tables. For Example, STUDENT database
may contain STUDENT and COURSE tables which will be visible to
users but users are unaware of their storage.Also referred as logical
schema,it describes what kind of data is to be stored in the database.
3. External Level: An external level specifies a view of the data in terms
of conceptual level tables. Each external level view is used to cater to
the needs of a particular category of users. For Example, FACULTY of
a university is interested in looking course details of students,
STUDENTS are interested in looking at all details related to
academics, accounts, courses and hostel details as well. So, different
views can be generated for different users. The main focus of external
level is data abstraction.

Data Independence
Data independence means a change of data at one level should not
affect another level. Two types of data independence are present in this
architecture:
1. Physical Data Independence: Any change in the physical location of
tables and indexes should not affect the conceptual level or external
view of data. This data independence is easy to achieve and
implemented by most of the DBMS.
2. Conceptual Data Independence: The data at conceptual level
schema and external level schema must be independent. This means
a change in conceptual schema should not affect external schema.
e.g.; Adding or deleting attributes of a table should not affect the
user’s view of the table. But this type of independence is difficult to
achieve as compared to physical data independence because the
changes in conceptual schema are reflected in the user’s view.

Difference between File System and


DBMS
File System :
The file system is basically a way of arranging the files in a storage
medium like a hard disk. The file system organizes the files and helps in
the retrieval of files when they are required. File systems consist of
different files which are grouped into directories. The directories further
contain other folders and files. The file system performs basic operations
like management, file naming, giving access rules, etc.

Difference between File System and DBMS:


Basis File System DBMS

The file system is software that


DBMS is software for
manages and organizes the files in a
managing the database.
Structure storage medium within a computer.
Basis File System DBMS

Data Redundant data can be present in a In DBMS there is no


Redundancy file system. redundant data.

It provides backup and


It doesn’t provide backup and
Backup and recovery of data even if it is
recovery of data if it is lost.
Recovery lost.

Query There is no efficient query Efficient query processing is


processing processing in the file system. there in DBMS.

There is more data


There is less data consistency in the
consistency because of the
file system.
Consistency process of normalization.

It has more complexity in


It is less complex as compared to
handling as compared to the
DBMS.
Complexity file system.

DBMS has more security


File systems provide less security in
Security mechanisms as compared to
comparison to DBMS.
Constraints file systems.

It has a comparatively higher


It is less expensive than DBMS.
Cost cost than a file system.

Data In DBMS data independence


There is no data independence.
Independence exists.
Basis File System DBMS

Only one user can access data at a Multiple users can access
User Access time. data at a time.

The user has to write procedures for The user not required to
Meaning managing databases write procedures.

Data is distributed in many files. So, Due to centralized nature


Sharing not easy to share data sharing is easy

Data It give details of storage and It hides the internal details


Abstraction representation of data of Database

Integrity Integrity Constraints are difficult to Integrity constraints are


Constraints implement easy to implement

Example Cobol, C++ Oracle, SQL Server

Introduction of ER Model
The Entity Relational Model is a model for identifying entities to be
represented in the database and representation of how those entities are
related. The ER data model specifies enterprise schema that represents
the overall logical structure of a database graphically.
The Entity Relationship Diagram explains the relationship among the
entities present in the database. ER models are used to model real-world
objects like a person, a car, or a company and the relation between these
real-world objects. In short, ER Diagram is the structural format of the
database.

Why Use ER Diagrams In DBMS?


 ER diagrams are used to represent the E-R model in a database,
which makes them easy to be converted into relations (tables).
 ER diagrams provide the purpose of real-world modeling of objects
which makes them intently useful.
 ER diagrams require no technical knowledge and no hardware
support.
 These diagrams are very easy to understand and easy to create even
for a naive user.
 It gives a standard solution for visualizing the data logically.

Symbols Used in ER Model


ER Model is used to model the logical view of the system from a data
perspective which consists of these symbols:
 Rectangles: Rectangles represent Entities in ER Model.
 Ellipses: Ellipses represent Attributes in ER Model.
 Diamond: Diamonds represent Relationships among Entities.
 Lines: Lines represent attributes to entities and entity sets with other
relationship types.
 Double Ellipse: Double Ellipses represent Multi-Valued Attributes.
 Double Rectangle: Double Rectangle represents a Weak Entity.

Components of ER Diagram
ER Model consists of Entities, Attributes, and Relationships among
Entities in a Database System.
Entity

An Entity may be an object with a physical existence – a particular


person, car, house, or employee – or it may be an object with a
conceptual existence – a company, a job, or a university course.
Entity Set: An Entity is an object of Entity Type and a set of all entities is
called an entity set. For Example, E1 is an entity having Entity Type
Student and the set of all students is called Entity Set. In ER diagram,
Entity Type is represented as:
1. Strong Entity
A Strong Entity is a type of entity that has a key Attribute. Strong Entity
does not depend on other Entity in the Schema. It has a primary key, that
helps in identifying it uniquely, and it is represented by a rectangle. These
are called Strong Entity Types.
2. Weak Entity
An Entity type has a key attribute that uniquely identifies each entity in
the entity set. But some entity type exists for which key attributes can’t be
defined. These are called Weak Entity types.
For Example, A company may store the information of dependents
(Parents, Children, Spouse) of an Employee. But the dependents don’t
have existed without the employee. So Dependent will be a Weak Entity
Type and Employee will be Identifying Entity type for Dependent, which
means it is Strong Entity Type.

A weak entity type is represented by a Double Rectangle. The


participation of weak entity types is always total. The relationship
between the weak entity type and its identifying strong entity type is
called identifying relationship and it is represented by a double diamond.

Attributes
Attributes are the properties that define the entity type. For example,
Roll_No, Name, DOB, Age, Address, and Mobile_No are the attributes
that define entity type Student. In ER diagram, the attribute is
represented by an oval.

1. Key Attribute
The attribute which uniquely identifies each entity in the entity set is
called the key attribute. For example, Roll_No will be unique for each
student. In ER diagram, the key attribute is represented by an oval with
underlying lines.
2. Composite Attribute
An attribute composed of many other attributes is called a composite
attribute. For example, the Address attribute of the student Entity type
consists of Street, City, State, and Country. In ER diagram, the composite
attribute is represented by an oval comprising of ovals.

3. Multivalued Attribute
An attribute consisting of more than one value for a given entity. For
example, Phone_No (can be more than one for a given student). In ER
diagram, a multivalued attribute is represented by a double oval.

4. Derived Attribute
An attribute that can be derived from other attributes of the entity type is
known as a derived attribute. e.g.; Age (can be derived from DOB). In ER
diagram, the derived attribute is represented by a dashed oval.

The Complete Entity Type Student with its Attributes can be represented
as:
Relationship Type and Relationship Set
A Relationship Type represents the association between entity types. For
example, ‘Enrolled in’ is a relationship type that exists between entity type
Student and Course. In ER diagram, the relationship type is represented
by a diamond and connecting the entities with lines.
A set of relationships of the same type is known as a relationship set. The
following relationship set depicts S1 as enrolled in C2, S2 as enrolled in
C1, and S3 as registered in C3.

Degree of a Relationship Set


The number of different entity sets participating in a relationship set is
called the degree of a relationship set.
1. Unary Relationship: When there is only ONE entity set participating in
a relation, the relationship is called a unary relationship. For example,
one person is married to only one person.

2.Binary Relationship: When there are TWO entities set participating in


a relationship, the relationship is called a binary relationship. For
example, a Student is enrolled in a Course.
3. n-ary Relationship: When there are n entities set participating in a
relation, the relationship is called an n-ary relationship.

Cardinality
The number of times an entity of an entity set participates in a
relationship set is known as cardinality. Cardinality can be of different
types:
1. One-to-One: When each entity in each entity set can take part only
once in the relationship, the cardinality is one-to-one. Let us assume that
a male can marry one female and a female can marry one male. So the
relationship will be one-to-one.
the total number of tables that can be used in this is 2.

Using Sets, it can be represented as:


2. One-to-Many: In one-to-many mapping as well where each
entity can be related to more than one relationship and the
total number of tables that can be used in this is 2.

Using sets, one-to-many cardinality can be represented as:

3. Many-to-One: When entities in one entity set can take part only once
in the relationship set and entities in other entity sets can take part more
than once in the relationship set, cardinality is many to one. Let us
assume that a student can take only one course but one course can be
taken by many students. So the cardinality will be n to 1. It means that for
one course there can be n students but for one student, there will be only
one course.
The total number of tables that can be used in this is 3.
Using Sets, it can be represented as:

In this case, each student is taking only 1 course but 1 course has
been taken by many students.

Using Sets, it can be represented as:

4. Many-to-Many: When entities in all entity sets can take part more than
once in the relationship cardinality is many to many. Let us assume that a
student can take more than one course and one course can be taken by
many students. So the relationship will be many to many.
the total number of tables that can be used in this is 3.

Using Sets, it can be represented as:


In this example, student S1 is enrolled in C1 and C3 and Course C3 is
enrolled by S1, S3, and S4. So it is many-to-many relationships.

Types of Keys in Relational Model


Keys are one of the basic requirements of a relational database model. It
is widely used to identify the tuples(rows) uniquely in the table. We also
use keys to set up relations amongst various columns and tables of a
relational database.
Different Types of Keys in the Relational Model
1. Candidate Key
2. Primary Key
3. Super Key
4. Alternate Key
5. Foreign Key
6. Composite Key
1. Candidate Key: The minimal set of attributes that can uniquely identify
a tuple is known as a candidate key. For Example, STUD_NO in
STUDENT relation.
 It is a minimal super key.
 It is a super key with no repeated data is called a candidate key.
 The minimal set of attributes that can uniquely identify a record.
 It must contain unique values.
 It can contain NULL values.
 Every table must have at least a single candidate key.
 A table can have multiple candidate keys but only one primary key
(the primary key cannot have a NULL value, so the candidate key with
a NULL value can’t be the primary key).
 The value of the Candidate Key is unique and may be null for a tuple.
 There can be more than one candidate key in a relationship.

Example:
STUD_NO is the candidate key for relation STUDENT.
Table STUDENT
STUD_NO SNAME ADDRESS PHONE

1 Shyam Delhi 123456789

2 Rakesh Kolkata 223365796

3 Suraj Delhi 175468965

2. Primary Key: There can be more than one candidate key in relation
out of which one can be chosen as the primary key. For Example,
STUD_NO, as well as STUD_PHONE, are candidate keys for relation
STUDENT but STUD_NO can be chosen as the primary key (only one
out of many candidate keys).
 It is a unique key.
 It can identify only one tuple (a record) at a time.
 It has no duplicate values, it has unique values.
 It cannot be NULL.
 Primary keys are not necessarily to be a single column; more than one
column can also be a primary key for a table.

Example:
STUDENT table -> Student(STUD_NO, SNAME,
ADDRESS, PHONE) , STUD_NO is a primary key
Table STUDENT
STUD_NO SNAME ADDRESS PHONE

1 Shyam Delhi 123456789

2 Rakesh Kolkata 223365796

3 Suraj Delhi 175468965

3. Super Key: The set of attributes that can uniquely identify a tuple is
known as Super Key. For Example, STUD_NO, (STUD_NO,
STUD_NAME), etc. A super key is a group of single or multiple keys that
identifies rows in a table. It supports NULL values.
 Adding zero or more attributes to the candidate key generates the
super key.
 A candidate key is a super key but vice versa is not true.

Example:
Consider the table shown above.
STUD_NO+PHONE is a super key.

Generalization
Generalization is a process of generalizing an entity which contains generalized
attributes or properties of generalized entities. The entity that is created will
contain the common features. Generalization is a Bottom up process.
We can have three sub entities as Car, Truck, Motorcycle and these
three entities can be generalized into one general super class as Vehicle.
Specialization
Specialization is a process of identifying subsets of an entity that shares different
characteristics. It breaks an entity into multiple entities from higher level (super
class) to lower level (sub class). The breaking of higher level entity is based on
some distinguishing characteristics of the entities in super class.
It is a top down approach in which we first define the super class and then sub
class and then their attributes and relationships.

Aggregation
Aggregation represents relationship between a whole object and its component.
Using aggregation we can express relationship among relationships.
Aggregation shows ‘has-a’ or ‘is-part-of’ relationship between entities where one
represents the ‘whole’ and other ‘part’.

You might also like