0% found this document useful (0 votes)
44 views24 pages

UNIT-1 DBMS AKTU Class Nots PDF

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 24

Data

Data is a collection of information gathered by observations, measurements, research or analysis. They


may consist of facts, numbers, names, figures or even description of things. Data is organized in the
form of graphs, charts or tables.

DataBase :- Database is a collection of well organized of interrelated data.


Database is a group of data. Data is stored in an organized manner in a database.
Data is stored in a database in a good manner so that this data can be easily accessed, managed
and updated when needed.
For example – A lot of books are stored in a library. That is, a library is a collection of many books. Here
the library is a database and books are data.

DBMS (Database Management System) is used to manage the database.

Database Management System:-


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

DBMS allows users the following tasks:


Data Definition: It helps in the creation, modification, and removal of definitions that define the
organization of data in the database.
Data Updation: It helps in the insertion, modification, and deletion of the actual data in the database.
Data Retrieval: It helps in the retrieval of data from the database which can be used by applications for
various purposes.
User Administration: It helps in registering and monitoring users, enforcing data security, monitoring
performance, maintaining data integrity, dealing with concurrency control, and recovering information
corrupted by unexpected failure.

Application of DBMS
Enterprise Information: Sales, accounting, human resources, Manufacturing, online retailers.
Banking and Finance Sector: Banks maintaining the customer details, accounts, loans, banking
transactions, credit card transactions. Finance: Storing the information about sales and holdings,
purchasing of financial stocks and bonds.
University: Maintaining the information about student course enrolled information, student grades,
staff roles.
Airlines: Reservations and schedules.
Telecommunications: Prepaid, postpaid bills maintance.

Advantages of Database Management System


 The advantages of database management systems are:
 Data Security: A Database Management System (DBMS) provides a better platform for data
privacy and security policies thus, helping companies to improve Data Security.
 Data integration: Due to the Database Management System we have access to well-managed
and synchronized forms of data thus it makes data handling very easy and gives an integrated
view of data.
 Data abstraction: The major purpose of a database system is to provide users with an abstract
view of the data. Since many complex algorithms are used by the developers to increase the
efficiency of databases that are being hidden by the users through various data abstraction
levels to allow users to easily interact with the system.
 Reduction in data Redundancy: When working with a structured database, DBMS provides the
feature to prevent the input of duplicate items in the database. for e.g. – If there are two same
students in different rows, then one of the duplicate data will be deleted.
 Data sharing: A DBMS provides a platform for sharing data across multiple applications and
users, which can increase productivity and collaboration.
 Data consistency and accuracy: DBMS ensures that data is consistent and accurate by enforcing
data integrity constraints and preventing data duplication. This helps to eliminate data
discrepancies and errors that can occur when data is stored and managed manually.

Disadvantages of DBMS
Increased Cost:
These are different types of costs:
1. Cost of Hardware and Software –
This is because, for DBMS, it is mandatory to have a high-speed processor and also a large
memory size.
2. Cost of Staff Training –
Educated staff (database administrator, application programmers, data entry operations) who
maintains the database management system also requires a good amount
3. Cost of Data Conversion-
This is because for this conversion we need to hire database system designers whom we have to
pay a lot of money and also services of some software house will be required.
4. Complexity:
5. Performance:

Difference between File System and DBMS


DBMS Architecture

o The DBMS design depends upon its architecture. The basic client/server
architecture is used to deal with a large number of PCs, web servers, database
servers and other components that are connected with networks.
o The client/server architecture consists of many PCs and a workstation which are
connected via the network.
o DBMS architecture depends upon how users are connected to the database to
get their request done.

Types of DBMS Architecture

Database architecture can divided into 3 type.

1-Tier Architecture

o In this architecture, the database is directly available to the user. It means the user can
directly sit on the DBMS and uses it.
o Any changes done here will directly be done on the database itself. It doesn't provide a
handy tool for end users.
o The 1-Tier architecture is used for development of the local application, where
programmers can directly communicate with the database for the quick response.

2-Tier Architecture

o The 2-Tier architecture is same as basic client-server. In the two-tier architecture,


applications on the client end can directly communicate with the database at the server
side. For this interaction, API's like: ODBC, JDBC are used.
o The user interfaces and application programs are run on the client-side.
o The server side is responsible to provide the functionalities like: query processing and
transaction management.
o To communicate with the DBMS, client-side application establishes a connection with the
server side.

Fig: 2-tier Architecture

3-Tier Architecture

o The 3-Tier architecture contains another layer between the client and server. In this
architecture, client can't directly communicate with the server.
o The application on the client-end interacts with an application server which further
communicates with the database system.
o End user has no idea about the existence of the database beyond the application server.
The database also has no idea about any other user beyond the application.
o The 3-Tier architecture is used in case of large web application.
Data Models
Data Model is the modeling of the data description, data semantics, and consistency constraints
of the data. It provides the conceptual tools for describing the design of a database at each level
of data Therefore, there are following four data models used for understanding the structure of
the database:

1) Relational Data Model: This type of model designs the data in the form of rows and
columns within a table. Thus, a relational model uses tables for representing data and
in-between relationships. Tables are also called relations. This model was initially
described by Edgar F. Codd, in 1969. The relational data model is the widely used model
which is primarily used by commercial data processing applications.

2) Entity-Relationship Data Model: An ER model is the logical representation of data as


objects and relationships among them. These objects are known as entities, and
relationship is an association among these entities. This model was designed by Peter
Chen and published in 1976 papers. It was widely used in database designing. A set of
attributes describe the entities. For example, student_name, student_id describes the
'student' entity. A set of the same type of entities is known as an 'Entity set', and the set
of the same type of relationships is known as 'relationship set'.

3) Object-based Data Model: An extension of the ER model with notions of functions,


encapsulation, and object identity, as well. This model supports a rich type system that
includes structured and collection types. Thus, in 1980s, various database systems
following the object-oriented approach were developed. Here, the objects are nothing
but the data carrying its properties.

4) Semistructured Data Model: This type of data model is different from the other three
data models (explained above). The semistructured data model allows the data
specifications at places where the individual data items of the same type may have
different attributes sets. The Extensible Markup Language, also known as XML, is widely
used for representing the semistructured data. Although XML was initially designed for
including the markup information to the text document, it gains importance because of
its application in the exchange of data.

Data Independence

o Data independence can be explained using the three-schema architecture.


o Data independence refers characteristic of being able to modify the schema at one level
of the database system without altering the schema at the next higher level.

There are two types of data independence:

1. Logical Data Independence


o Logical data independence refers characteristic of being able to change the
conceptual schema without having to change the external schema.
o Logical data independence is used to separate the external level from the
conceptual view.
o If we do any changes in the conceptual view of the data, then the user view of the
data would not be affected.
o Logical data independence occurs at the user interface level.

2. Physical Data Independence


o Physical data independence can be defined as the capacity to change
the internal schema without having to change the conceptual schema.
o If we do any changes in the storage size of the database system
server, then the Conceptual structure of the database will not be
affected.
o Physical data independence is used to separate conceptual levels
from the internal levels.
o Physical data independence occurs at the logical interface level.
Database Languages in DBMS

o A DBMS has appropriate languages and interfaces to express database queries and
updates.
o Database languages can be used to read, store and update the data in the database.

Types of Database Languages (SQL)

1. Data Definition Language (DDL)


o DDL stands for Data Definition Language. It is used to define database structure or
pattern.
o It is used to create schema, tables, indexes, constraints, etc. in the database.
o Using the DDL statements, you can create the skeleton of the database.
o Data definition language is used to store the information of metadata like the number of
tables and schemas, their names, indexes, columns in each table, constraints, etc.

Here are some tasks that come under DDL:

o Create: It is used to create objects in the database.


o Alter: It is used to alter the structure of the database.
o Drop: It is used to delete objects from the database.
o Truncate: It is used to remove all records from a table.
o Rename: It is used to rename an object.
o Comment: It is used to comment on the data dictionary.
These commands are used to update the database schema that's why they come under Data
definition language.

2. Data Manipulation Language (DML)

DML stands for Data Manipulation Language. It is used for accessing and
manipulating data in a database. It handles user requests.

Here are some tasks that come under DML:

o Select: It is used to retrieve data from a database.


o Insert: It is used to insert data into a table.
o Update: It is used to update existing data within a table.
o Delete: It is used to delete all records from a table.
o Merge: It performs UPSERT operation, i.e., insert or update operations.
o Call: It is used to call a structured query language or a Java subprogram.
o Explain Plan: It has the parameter of explaining data.
o Lock Table: It controls concurrency.

3. Data Control Language (DCL)


o DCL stands for Data Control Language. It is used to retrieve the stored or saved
data.
o The DCL execution is transactional. It also has rollback parameters.

(But in Oracle database, the execution of data control language does not have
the feature of rolling back.)

Here are some tasks that come under DCL:

o Grant: It is used to give user access privileges to a database.


o Revoke: It is used to take back permissions from the user.

There are the following operations which have the authorization of Revoke:

CONNECT, INSERT, USAGE, EXECUTE, DELETE, UPDATE and SELECT.

4. Transaction Control Language (TCL)


TCL is used to run the changes made by the DML statement. TCL can be grouped into a
logical transaction.

Here are some tasks that come under TCL:

o Commit: It is used to save the transaction on the database.


o Rollback: It is used to restore the database to original since the last Commit.

ER (Entity Relationship) Diagram in DBMS


o ER model stands for an Entity-Relationship model. It is a high-level data model. This model is used to define the data
elements and relationship for a specified system.
o It develops a conceptual design for the database. It also develops a very simple and easy to design view of data.
o In ER modeling, the database structure is portrayed as a diagram called an entity-relationship diagram.

For example, suppose we design a school database. In this database, the student will be an entity with attributes like address, name,
id, age, etc. The address can be another entity with attributes like city, street name, pin code, etc and there will be a relationship
between them.

Component of ER Diagram
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 the ER Model.
Ellipses: Ellipses represent Attributes in the 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.
Notation of ER diagram

Database can be represented using the notations. In ER diagram, many notations are used to express the
cardinality. These notations are as follows:
Key:-

A key is an attribute (Colum) or set of attribute that uniquely identify any


row (tuple) from the database table.

It is also used to establish and identify relationship between tables.

Types of keys:

1. Super Key

A Super key is a combination of all possible attributes that can uniquely identify the
row(or tuple) in the given relation
2. Super key is a superset of candidate key.
3. A table can have much supper key.
4. A super key may have additional attribute that are not needed for unique identity and
have null value.

…etc

2. Candidate Key :-
A Candidate key is an attribute or set of an attribute which can uniquely identify a
tuple(row).
It is also called the minimal super Key because we select of candidate key form set of
super key such that select candidate key is the minimum attribute required to uniquely
identify a tuple.

1. It is the minimal super key


2. Candidate key is the subset of super key.
3. A table can have many candidates key.
4. Candidate key have not allow the null value.
3. Primary Key :-
A primary key is one pf the candidate key chosen by the database designer
to uniquely identify the tuple in the relation.

 The value of primary key can never br NULL.


 The value of primary key must always be unique (not duplicate).
 The value of primary key can never be changed (no updation is possible)
 The value of primary key must be assigned when inserting a record in table.
 A relation is allowed to have only one primary key.

4. Alternate Key: - Out of all Candidate keys, Only one gets selected as primary key,
remaining Keys are known as alternative Keys.

In the above Table, Emp _id is the best suitable for primary key so rest of candidate key
(Email_id , Addhar_no) are considered as candidate key
5. Foreign Key :-
A key used to link two tables together.
An attribute or set of attributes in one table that refer to the primary key in another
table.
Foreign key is ensure (or maintain) referential integrity of the data.

 Foreign Key references the primary key of the table


 Foreign key can take only those values which are present in the primary key of the
referenced relation.
 Foreign key may have a name other than that of a primary key.
 Foreign key can take the NULL value.
 There is no restriction on a foreign key to be unique.
 In fact, foreign key is not unique most of the time.
 Referenced relation may also be called as the master table or primary table.
 Referencing relation may also be called as the foreign table.
Generalization:-

o Generalization is like a bottom-up approach in which two or more entities of lower


level combine to form a higher level entity if they have some attributes in
common.
o In generalization, an entity of a higher level can also combine with the entities of
the lower level to form a further higher level entity.
o Generalization is more like subclass and superclass system, but the only
difference is the approach. Generalization uses the bottom-up approach.
o In generalization, entities are combined to form a more generalized entity, i.e.,
subclasses are combined to make a superclass.

Example1:- Faculty and Student entities can be generalized and create a higher level entity Person.

Example-2
Specialization:-

o Specialization is a top-down approach, and it is opposite to Generalization. In


specialization, one higher level entity can be broken down into two lower level
entities.
o Specialization is used to identify the subset of an entity set that shares some
distinguishing characteristics.
o Normally, the superclass is defined first, the subclass and its related attributes
are defined next, and relationship set are then added.

Example1 : In an Employee management system, EMPLOYEE entity can be specialized as TESTER or


DEVELOPER based on what role they play in the company.

Example2 :-
Note:- Inheritance is an important feature of generalization and specialization in
below diagram are showing the both activity (bottom –up approach and top-down
approach)

Example 2:-
Aggregation:- Aggregation is used when need to express a relationship among
relationship .

In another word,aggregation is a process when a relationship between two


entities is considered as a single entity and again this single entity has a
relationship with another entity.

Eliminate this redundancy via aggregation

1. Treat relationship as an abstract entity.


2. Allows relationships between relationship.
3. Abstraction of relationship into new entity.
Reduction of ER diagram to Table

The database can be represented using the notations, and these notations can be
reduced to a collection of tables.

In the database, every entity set or relationship set can be represented in tabular
form.

The ER diagram is given below:

There are some points for converting the ER diagram to the table:

Entity type becomes a table.

In the given ER diagram, LECTURE, STUDENT, SUBJECT and COURSE forms individual tables.

All single-valued attribute becomes a column for the table.

In the STUDENT entity, STUDENT_NAME and STUDENT_ID form the column of STUDENT table.
Similarly, COURSE_NAME and COURSE_ID form the column of COURSE table and so on.

A key attribute of the entity type represented by the primary key.


In the given ER diagram, COURSE_ID, STUDENT_ID, SUBJECT_ID, and LECTURE_ID are the key
attribute of the entity.

The multivalued attribute is represented by a separate table.

In the student table, a hobby is a multivalued attribute. So it is not possible to represent multiple
values in a single column of STUDENT table. Hence we create a table STUD_HOBBY with column
name STUDENT_ID and HOBBY. Using both the column, we create a composite key.

Composite attribute represented by components.

In the given ER diagram, student address is a composite attribute. It contains CITY, PIN, DOOR#,
STREET, and STATE. In the STUDENT table, these attributes can merge as an individual column.

Derived attributes are not considered in the table.

In the STUDENT table, Age is the derived attribute. It can be calculated at any point of time by
calculating the difference between current date and Date of Birth.

Using these rules, you can convert the ER diagram to tables and columns and assign the mapping
between the tables. Table structure for the given ER diagram is as below:
Relationship of higher degree

The degree of relationship can be defined as the number of occurrences in one entity that is associated with the
number of occurrences in another entity.

There is the three degree of relationship:

1. One-to-one (1:1)
2. One-to-many (1:M)
3. Many-to-many (M:N)

1. One-to-one

o In a one-to-one relationship, one occurrence of an entity relates to only one occurrence in another entity.
o A one-to-one relationship rarely exists in practice.
o For example: if an employee is allocated a company car then that car can only be driven by that employee.
o Therefore, employee and company car have a one-to-one relationship.

2. One-to-many

o In a one-to-many relationship, one occurrence in an entity relates to many occurrences in another entity.
o For example: An employee works in one department, but a department has many employees.
o Therefore, department and employee have a one-to-many relationship.

3. Many-to-many

o In a many-to-many relationship, many occurrences in an entity relate to many occurrences in another entity.
o Same as a one-to-one relationship, the many-to-many relationship rarely exists in practice.
o For example: At the same time, an employee can work on several projects, and a project has a team of many
employees.
o Therefore, employee and project have a many-to-many relationship.

You might also like