Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

DBMS (UNIT-1 & UNIT- 1.5) Notes 1st Sessional

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

UNIT-1

Database Management System Concept:

Data:

 It is a collection of information.
 The facts that can be recorded and which have implicit meaning known as 'data'.
 Example: Customer ----- 1. cname. 2. cno. 3. ccity

Database:
 It is a collection of interrelated data.
 These can be stored in the form of tables.
 A database can be of any size and varying complexity.
 A database may be generated and manipulated manually or it may be computerized.
 Example: Customer database consists the fields as cname, cno, and ccity.

Database System:
It is computerized system, whose overall purpose is to maintain the information and to make that the
information is available on demand.
Advantages:
1. Redundancy can be reduced.
2. Inconsistency can be avoided.
3. Data can be shared.
4. Standards can be enforced.
5. Security restrictions can be applied.
6. Integrity can be maintained.
7. Data gathering can be possible.
8. Requirements can be balanced.

Database Management System (DBMS):


It is a collection of programs that enables user to create and maintain a database. In other words, it is
general-purpose software that provides the users with the processes of defining, constructing and
manipulating the database for various applications.
Disadvantages in File Processing
 Data redundancy and inconsistency.
 Difficult in accessing data.
 Data isolation.
 Data integrity.
 Concurrent access is not possible.
 Security Problems.
Advantages of DBMS:
 Data Independence.
 Efficient Data Access.
 Data Integrity and security.
 Data administration.
 Concurrent access and Crash recovery.
 Reduced Application Development Time.
Applications of Database Applications:
 Banking: all transactions
 Airlines: reservations, schedules
 Universities: registration, grades
 Sales: customers, products, purchases Online retailers: order tracking, customized
recommendations
 Manufacturing: production, inventory, orders, supply chain
 Human resources: employee records, salaries, tax deductions

Types of Database Users


Database users are categorized based on their interaction with the database. There are seven types of
database users in DBMS. Below mentioned are the types of database users:

1. Database Administrator (DBA)


A Database Administrator (DBA) is a person/team who defines the schema and also controls the 3 levels
of the database. The DBA will then create a new account ID and password for the user if he/she needs to
access the database. DBA is also responsible for providing security to the database and he allows only
authorized users to access/modify the database. DBA is responsible for problems such as security
breaches and poor system response time.
DBA also monitors the recovery and backup and provides technical support.
The DBA has a DBA account in the DBMS which is called a system or superuser account.
DBA repairs damage caused due to hardware and/or software failures.
DBA is the one having privileges to perform DCL (Data Control Language) operations such as GRANT
and REVOKE, to allow/restrict a particular user from accessing the database.

2. Naive / Parametric End Users


Parametric End Users are the unsophisticated who don‟t have any DBMS knowledge but they frequently
use the database applications in their daily life to get the desired results. For example, Railway‟s ticket
booking users are naive users. Clerks in any bank is a naive user because they don‟t have any DBMS
knowledge but they still use the database and perform their given task.

3. A System Analyst
A system Analyst is a user who analyzes the requirements of parametric end users. They check whether
all the requirements of end users are satisfied.

4. Sophisticated Users
Sophisticated users can be engineers, scientists, business analyst, who are familiar with the database.
They can develop their own database applications according to their requirement. They don‟t write the
program code but they interact the database by writing SQL queries directly through the query processor.

5. Database Designers
Data Base Designers are the users who design the structure of database which includes tables, indexes,
views, triggers, stored procedures and constraints which are usually enforced before the database is
created or populated with data. He/she controls what data must be stored and how the data items to be
related. It is the responsibility of Database Designers to understand the requirements of different user
groups and then create a design which satisfies the need of all the user groups.

6. Application Programmers
Application Programmers also referred as System Analysts or simply Software Engineers, are the back-
end programmers who writes the code for the application programs. They are the computer professionals.
These programs could be written in Programming languages such as Visual Basic, Developer, C,
FORTRAN, COBOL etc. Application programmers design, debug, test, and maintain set of programs
called “canned transactions” for the Naive (parametric) users in order to interact with database.

7. Casual Users / Temporary Users


Casual Users are the users who occasionally use/access the database but each time when they access the
database they require the new information, for example, Middle or higher level manager.

8. Specialized users
Specialized users are sophisticated users who write specialized database application that does not fit into
the traditional data-processing framework. Among these applications are computer aided-design systems,
knowledge-base and expert systems etc.

Introduction to Traditional File System:


File system is collection of data. In this system, user has to write procedures for managing database. It
provides details of data representation and storage of data. In this –
 Data is stored in files.
 Each file has specific format.
 Programs that use these files depend on knowledge about that format.
 In earlier days, database applications were built on top of file systems.

This approach is mostly obsolete but –

 Understanding problems inherent in file based systems may prevent us from repeating these
problems in our database system.
 Understanding how file system works is extremely useful when converting a file-based system to
a database system.

Basically, it is a collection of application programs that performs services for end users such as
production of reports. Each file defines and manages its own data. It doesn‟t have a crash mechanism i.e.,
if system crashes while entering some data, then content of file will be lost. This is disadvantage of
traditional file based system. Also, it is very difficult to protect a file under the file system. This system
can‟t efficiently store and retrieve data.

Advantages of Traditional File System :


 File processing cost less and can be more speed than database.
 File processing design approach was well suited to mainframe hardware and batch input.
 Companies mainly use file processing to handle large volumes of structured data on a regular
basis.
 It can be more efficient and cost less than DBMS in certain situations.
 Design is simple.
 Customization is easy and efficient.
Disadvantages of Traditional File System :
 Data redundancy and inconsistency.
 Difficulty in accessing data.
 Data isolation – multiple files and formats.
 Integrity problems
 Unauthorized access is not restricted.
 It co-ordinates only physical access.
Difference between File System and Database Management System:

Basis DBMS Approach File System Approach

Meaning DBMS is a collection of data. In DBMS, The file system is a collection of data.
the user is not required to write the In this system, the user has to write the
procedures. procedures for managing the database.

Sharing of data Due to the centralized approach, data Data is distributed in many files, and it
sharing is easy. may be of different formats, so it isn't
easy to share data.

Data Abstraction DBMS gives an abstract view of data that The file system provides the detail of
hides the details. the data representation and storage of
data.

Security and DBMS provides a good protection It isn't easy to protect a file under the
Protection mechanism. file system.

Recovery DBMS provides a crash recovery The file system doesn't have a crash
Mechanism mechanism, i.e., DBMS protects the user mechanism, i.e., if the system crashes
from system failure. while entering some data, then the
content of the file will be lost.

Manipulation DBMS contains a wide variety of The file system can't efficiently store
Techniques sophisticated techniques to store and and retrieve the data.
retrieve the data.

Concurrency DBMS takes care of Concurrent access of In the File system, concurrent access
Problems data using some form of locking. has many problems like redirecting the
file while deleting some information or
updating some information.

Where to use Database approach used in large systems File system approach used in large
which interrelate many files. systems which interrelate many files.

Cost The database system is expensive to The file system approach is cheaper to
design. design.

Data Due to the centralization of the database, In this, the files and application
Redundancy and the problems of data redundancy and programs are created by different
Inconsistency inconsistency are controlled. programmers so that there exists a lot
of duplication of data which may lead
to inconsistency.

Structure The database structure is complex to The file system approach has a simple
design. structure.

Data In this system, Data Independence exists, In the File system approach, there
Independence and it can be of two types. exists no Data Independence.
o Logical Data Independence
o Physical Data Independence

Integrity Integrity Constraints are easy to apply. Integrity Constraints are difficult to
Constraints implement in file system.

Data Models In the database approach, 3 types of data In the file system approach, there is no
models exist: concept of data models exists.
o Hierarchal data models
o Network data models
o Relational data models

Flexibility Changes are often a necessity to the The flexibility of the system is less as
content of the data stored in any system, compared to the DBMS approach.
and these changes are more easily with a
database approach.

Examples Oracle, SQL Server, Sybase etc. Cobol, C++ etc.

Characteristics of Database Approach:


A number of characteristics distinguish the database approach from the much older approach of
programming with files. In traditional file processing, each user defines and implements the files needed for
a specific software application as part of programming the application. The main characteristics of the
database approach versus the file-processing approach are the following:
 Self-describing nature of a database system.
 Insulation between programs and data, and data abstraction.
 Support of multiple views of the data.
 Sharing of data and multiuser transaction processing.
The database approach has some very characteristic features which are discussed in detail below:
1. Structured and Described Data:
 Fundamental feature of the database approach is that the database system does not only contain
the data but also the complete definition and description of these data.
 These descriptions are basically details about the extent, the structure, the type and the format of
all data and, additionally, the relationship between the data. This kind of stored data is called
metadata ("data about data").
2. Separation of Data and Applications:
 Application software does not need any knowledge about the physical data storage like encoding,
format, storage place, etc. It only communicates with the management system of a database
(DBMS) via a standardized interface with the help of a standardized language like SQL.
3. Data Integrity:
 Data integrity is a byword for the quality and the reliability of the data of a database system.
 In a broader sense data integrity includes also the protection of the database from unauthorized
access (confidentiality) and unauthorized changes. Data reflect facts of the real world.
4. Transactions:
 A transaction is a bundle of actions which are done within a database to bring it from one
consistent state to a new consistent state. In between the data are inevitable inconsistent.
5. Data Persistence:
 Data persistence means that in a DBMS all data is maintained as long as it is not deleted
explicitly.
 The life span of data needs to be determined directly or indirectly be the user and must not be
dependent on system features.
 Additionally, data once stored in a database must not be lost. Changes of a database which are
done by a transaction are persistent.
 When a transaction is finished even a system crash cannot put the data in danger.

Components of DBMS
There are many components available in the DBMS. Each component has a significant task in the DBMS.
A database environment is a collection of components that regulates the use of data, management, and a
group of data. These components consist of people, the technique of Handel the database, data, hardware,
software, etc. there are several components available for the DBMS. We are going to explain five main
topics of the database below.

The five major components of a database are:

1. Hardware
Hardware refers to the physical, electronic devices such as computers and hard disks that offer the
interface between computers and real-world systems.
2. Software
Software is a set of programs used to manage and control the database and includes the database software,
operating system, network software used to share the data with other users, and the applications used to
access the data.
3. Data
Data are raw facts and information that need to be organized and processed to make it more meaningful.
Database dictionaries are used to centralize, document, control, and coordinate the use of data within an
organization. A database is a repository of information about a database (also called metadata).
4. Procedures
Procedures refer to the instructions used in a database management system and encompass everything
from instructions to setup and install, login and logout, manage the day-to-day operations, take backups
of data, and generate reports.
5. Database Access Language
Database Access Language is a language used to write commands to access, update, and delete data
stored in a database. Users can write commands using Database Access Language before submitting them
to the database for execution. Through utilizing the language, users can create new databases, tables,
insert data, and delete data.

Advantages and disadvantages of Using a DBMS


Advantages of DBMS
DBMS has a wide variety of advantages that make it very desirable for a myriad of companies. These
include:

1. Improved data security


Data security measures are very important for any organization. To ensure high data security, companies
use DBMS as it provides various levels of security authentication which can be done at the user and
admin levels. This helps to avoid security breaches and takes care of the security issues.
2. Data retrieval
DBMS provides a platform that is time-saving and easy to use for organizations. Data can be stored and
retrieved quickly and securely within time constraints.
3. Minimum data inconsistency
Data inconsistency occurs when there are different versions of the same data stored at different places.
For example, data inconsistency exists when let‟s say a school‟s database has the name of the Principal as
'Raman Desai' at one place and it‟s 'Naman Desai' at the other place. Here, there‟s an inconsistency as the
principal is the same and it should be the same at all places in a database. Such errors are highly
minimized in a properly designed DBMS.
4. Improved decision making
DBMS provides high data quality by minimizing data inconsistency and improving data security. This
ensures that there are fewer errors and high accuracy rate is maintained. Thus, DBMS helps businesses to
improve upon their decisions that are backed by the data in a DBMS.
5. Better data sharing facility
DBMS ensures that database users have access to the data. They can see the data and the changes
happening in that data. Then, the end-users can also respond quickly to such updates in the database.
6. Improved data integration
DBMS gives companies an integrated view of their organization‟s operations and departments. It helps
companies to see how one segment of their company is affecting the other one.
7. Good data back-up
Imagine yourself working on an important task, and suddenly the system crashes. How would you feel?
Obviously, you‟ll get angry and irritated. In the case of organizations, they can‟t afford such errors. So, in
such cases, DBMS comes to their rescue by enabling data recovery and backup.

Disadvantages of DBMS
Apart from the advantages, there are a few demerits of using DBMS. Let‟s have a look at some of the
important ones:
1. DBMS is expensive
DBMS requires highly professional staff, sophisticated hardware and software that make it quite
expensive to implement and maintain. Also, training costs for staff and licensing costs are significant ones
that add to the total cost of DBMS operations. Thus, heavy investment in database technology results in
DBMS being expensive.
2. Complexity issues
DBMS is very complex to operate and manage. It requires skilled personnel to maintain, so it‟s difficult
for non-technical people to understand it‟s working. If one doesn‟t use DBMS properly, then there can be
system failure issues. These issues can lead to database failure or data loss.
3. Not beneficial for small firms
DBMS is designed to be useful for large organizations. Generally, traditional file systems work better for
small-scale firms as compared to DBMS. This is because the performance of DBMS is slow for small
firms. Also, it‟s quite expensive for them to use DBMS.
4. Frequent upgrade issue
As updates occur in a system, new features are added to its functionality. This makes it necessary for staff
to learn about these software and hardware upgrades. As in today‟s world, changes occur rapidly, so it
takes time, effort, and cost for organizations to train their staff.

DBMS Structure

1. Query Processor
The Query Processor receives the queries (requests) from the user and interprets them in the form of
instructions. It also executes the instructions received from the DML Compiler. It has the following four
components:

DML Compiler: It converts the DML (Data Manipulation Language) Instructions into Machine
Language (low-level language).
DDL Interpreter: It interprets the DDL (Data Definition Language) Instructions and stores the record in
a data dictionary (in a table containing meta-data)
Query Optimizer: It executes the DML Instructions and picks the lowest cost evaluation plan out of all
the alternatives present.
Embedded DML Pre-compiler: It translates the DML statements embedded in Application Programs
into procedural function calls.

2. Storage Manager
Storage manager acts as the interface between the data stored in the database and the queries received
from the end-user. This component in the Structure of DBMS is responsible for the constraints applied to
the data so that it remains consistent. It also executes the DCL (Data Control Language). It encapsulates
the following modules:

Authorization and Integrity Manager: It checks the authority of various users who access data and the
Integrity Constraints of the database.
Transaction Manager: Its job is to assure the system remains in a proper state during the transaction
process. It also ensures that concurrent transactions are executed without any conflict.
File Manager: It manages the space allocation of files in disk and data structures which stores
information in the database.
Buffer Manager: It manages the transfer of data between the secondary and main memory. It also
decides what data should be cached in the memory.

3. Disk Storage
The Disk Storage in the Structure of DBMS represents the space where data is stored. It has the following
components:

Files: These are responsible for storing the data.


Data Dictionary: It is the repository that maintains the information of the database object and maintains
the metadata.
Indices: These are the keys that are used for faster retrieval of data.

A Database stores a lot of critical information to access data quickly and securely. Hence it is important to
select the correct architecture for efficient data management. DBMS Architecture helps users to get their
requests done while connecting to the database. We choose database architecture depending on several
factors like the size of the database, number of users, and relationships between the users. There are two
types of database models that we generally use, logical model and physical model. Several types of
architecture are there in the database which we will deal with in the next section.

Types of DBMS Architecture


There are several types of DBMS Architecture that we use according to the usage requirements. Types of
DBMS Architecture are discussed here.

1-Tier Architecture
2-Tier Architecture
3-Tier Architecture

1-Tier Architecture
In 1-Tier Architecture the database is directly available to the user, the user can directly sit on the DBMS
and use it that is, and the client, server, and Database are all present on the same machine. For Example:
to learn SQL we set up an SQL server and the database on the local system. This enables us to directly
interact with the relational database and execute operations. The industry won‟t use this architecture they
logically go for 2-tier and 3-tier Architecture.
Advantages of 1-Tier Architecture

Simple Architecture: 1-Tier Architecture is the most simple architecture to set up, as only a single
machine is required to maintain it.
Cost-Effective: No additional hardware is required for implementing 1-Tier Architecture, which makes it
cost-effective.
Easy to Implement: 1-Tier Architecture can be easily deployed, and hence it is mostly used in small
projects.

2-Tier Architecture
The 2-tier architecture is similar to a basic client-server model. The application at the client end directly
communicates with the database on the server side. APIs like ODBC and JDBC are used for this
interaction. The server side is responsible for providing query processing and transaction management
functionalities. On the client side, the user interfaces and application programs are run. The application on
the client side establishes a connection with the server side to communicate with the DBMS. An
advantage of this type is that maintenance and understanding are easier, and compatible with existing
systems. However, this model gives poor performance when there are a large number of users.

Advantages of 2-Tier Architecture


Easy to Access: 2-Tier Architecture makes easy access to the database, which makes fast retrieval.
Scalable: We can scale the database easily, by adding clients or upgrading hardware.
Low Cost: 2-Tier Architecture is cheaper than 3-Tier Architecture and Multi-Tier Architecture.
Easy Deployment: 2-Tier Architecture is easier to deploy than 3-Tier Architecture.
Simple: 2-Tier Architecture is easily understandable as well as simple because of only two components.

3-Tier Architecture
In 3-Tier Architecture, there is another layer between the client and the server. The client does not
directly communicate with the server. Instead, it interacts with an application server which further
communicates with the database system and then the query processing and transaction management takes
place. This intermediate layer acts as a medium for the exchange of partially processed data between the
server and the client. This type of architecture is used in the case of large web applications.
Advantages of 3-Tier Architecture
Enhanced scalability: Scalability is enhanced due to the distributed deployment of application servers.
Now, individual connections need not be made between the client and server.
Data Integrity: 3-Tier Architecture maintains Data Integrity. Since there is a middle layer between the
client and the server, data corruption can be avoided/removed.
Security: 3-Tier Architecture Improves Security. This type of model prevents direct interaction of the
client with the server thereby reducing access to unauthorized data.
Disadvantages of 3-Tier Architecture
More Complex: 3-Tier Architecture is more complex in comparison to 2-Tier Architecture.
Communication Points are also doubled in 3-Tier Architecture.
Difficult to Interact: It becomes difficult for this sort of interaction to take place due to the presence of
middle layers.

Database Schema
Definition: A database schema is a blueprint or architecture of how the data will be organized within a
database. It defines the structure of the database, including the tables, fields, relationships, views, indexes,
and other elements.
Types of Schemas:
Physical Schema: Describes how the data is physically stored on storage devices. It includes information
about the file formats, indices, and storage structures.
Logical Schema: Describes the structure of the database at a logical level. It includes tables, views, and
relationships without considering how they are physically stored.
External Schema: Also known as user views, this schema represents how different users or user groups
view the data in the database. It can provide different views of the same underlying database for different
users.
Schema Components:
Tables: The core entities that store data in rows and columns.
Fields/Columns: Attributes or properties of the entities.
Relationships: Defines how tables are related to one another.
Constraints: Rules enforced on data in the database to ensure integrity (e.g., primary keys, foreign keys,
uniqueness).
Indexes: Special lookup tables that the database search engine can use to speed up data retrieval.
Example: For a university database, a schema might include tables like Students, Courses, and
Enrollments. Each table would have fields (columns) like StudentID, CourseID, EnrollmentDate, etc.
Relationships would define how Students are associated with Courses through Enrollments.

Database Instance
Definition: A database instance is the actual data stored in the database at any given point in time. It is a
snapshot of the database schema filled with data.
Characteristics:
Dynamic: The instance can change frequently as data is added, updated, or deleted.
Data Representation: While the schema defines the structure, the instance represents the actual content
of the database at a specific moment.
Multiple Instances: Multiple instances can exist for the same schema over time, reflecting different
states of the data.
Example: Continuing with the university database example, at a specific moment, the Students table
might contain records for students currently enrolled. As new students enroll or existing students
graduate, the instance of the Students table changes, even though the schema remains the same.
Schema vs. Instance
Schema:
1. Static and stable over time.
2. Defines the design and structure of the database.
3. Independent of the actual data stored.
Instance:
1. Dynamic and changes over time.
2. Represents the actual data in the database at a specific moment.
3. Depends on the schema for its structure but varies based on the data.
Importance in DBMS
Schema: Provides a consistent structure that the database management system (DBMS) follows to
organize, store, and retrieve data efficiently.
Instance: Reflects the current state of the data, which is critical for operations, transactions, and querying
in a DBMS.

Data Independence
Definition:
Data Independence is the capacity to change the schema at one level of a database system without altering
the schema at the next higher level. This property is crucial for the flexibility and maintainability of a
database system, allowing changes to be made to the database structure without affecting the overall
system or application programs.
Types of Data Independence
Logical Data Independence:
Definition: The ability to change the logical schema without altering the external schema or application
programs. Logical schema changes might include adding or removing tables, fields, or relationships.
Importance: This type of independence ensures that modifications to the logical structure of the
database, such as adding a new field or changing relationships between tables, do not require changes to
the application programs.
Example: If a new field, Email, is added to the Student table, the existing applications using the Student
table should continue to function without modification.
Physical Data Independence:
Definition: The ability to change the physical schema without altering the logical schema or application
programs. Physical schema changes might include changing the storage structure, indexing, or file
organization.
Importance: This type of independence allows the database administrator to optimize the storage and
retrieval mechanisms without affecting the logical view of the data or the user interactions with the
database.
Example: If the Student table is moved to a different physical location or indexed differently for
performance reasons, this change should not affect how the Student table is accessed at the logical level.
Importance of Data Independence
Flexibility: Allows the database structure to evolve without requiring changes to the entire system.
Maintainability: Facilitates easier maintenance and upgrading of the database system, as changes in one
part do not necessitate changes in dependent parts.
Cost Efficiency: Reduces the cost and complexity associated with modifying the database, particularly
when changes are frequent or the database is large and complex.

Database Languages
Database languages are specialized languages used to define, manipulate, control, and retrieve data from a
database. These languages are integral to the operation of a Database Management System (DBMS).
1. Data Definition Language (DDL)
Purpose: DDL is used to define the database schema. It allows the creation, alteration, and deletion of
database objects such as tables, indexes, and views.
Common Commands:
CREATE: Used to create database objects like tables, views, and indexes.
ALTER: Used to modify the structure of existing database objects.
DROP: Used to delete existing database objects.
TRUNCATE: Used to remove all records from a table, but not the table itself.
2. Data Manipulation Language (DML)
Purpose: DML is used for data manipulation within the database. It allows for inserting, updating,
deleting, and retrieving data from the database.
Common Commands:
INSERT: Adds new records to a table.
UPDATE: Modifies existing records in a table.
DELETE: Removes records from a table.
SELECT: Retrieves data from one or more tables.
3. Data Control Language (DCL)
Purpose: DCL is used to control access to data within the database. It manages user permissions and
controls access to database objects.
Common Commands:
GRANT: Provides specific privileges to users.
REVOKE: Removes specific privileges from users.
Transaction Control Language (TCL)
Purpose: TCL manages transactions within the database, ensuring that all operations within a transaction
are completed successfully before committing the changes.
Common Commands:
COMMIT: Saves all changes made during the current transaction.
ROLLBACK: Undoes all changes made during the current transaction.
SAVEPOINT: Sets a point within a transaction to which a rollback can occur.

Database Interfaces
Database interfaces are the tools and mechanisms through which users interact with the database. These
interfaces can vary depending on the type of user, ranging from developers and database administrators to
end-users.
1. Command-Line Interface (CLI)
Purpose: CLI allows users to interact with the database using text-based commands. It is commonly used
by database administrators and developers for executing queries, managing database objects, and
troubleshooting issues.
Example: SQL*Plus in Oracle, MySQL command-line tool.
2. Graphical User Interface (GUI)
Purpose: GUI provides a visual and more user-friendly way to interact with the database. It typically
includes forms, buttons, and visual representations of database objects, making it easier for non-technical
users to interact with the database.
Example: phpMyAdmin for MySQL, Oracle SQL Developer.
3. Application Program Interface (API)
Purpose: API allows external applications to interact with the database programmatically. It provides a
set of functions or protocols that applications can use to send queries, retrieve data, and perform other
database operations.
Example: JDBC (Java Database Connectivity), ODBC (Open Database Connectivity).
4. Web-Based Interface
Purpose: Web-based interfaces allow users to interact with the database through a web browser. These
interfaces are often used for database administration tasks, data entry, and reporting.
Example: phpMyAdmin, Webmin.
5. Embedded SQL
Purpose: Embedded SQL allows SQL code to be embedded within a host programming language, such
as C, Java, or Python. This enables applications to interact with the database directly from within the
code.
Example: A Java program using JDBC to execute SQL queries within a Java application.
Importance of Database Languages and Interfaces
Database Languages: These provide the necessary syntax and commands to define, manipulate, and
control data within a database. They are essential for building and maintaining database systems.
Database Interfaces: These ensure that users and applications can interact with the database in a way
that suits their needs, whether through direct command-line access, graphical interfaces, or programmatic
interactions.

Classification of Database Management Systems (DBMS)


Database Management Systems (DBMS) can be classified based on various criteria such as data models,
the number of users, database distribution, and the type of access provided. Here's an overview of the
different classifications:

1. Classification Based on Data Models


Data models define the structure of the database and determine how data is stored, organized, and
manipulated.

Hierarchical DBMS:
Structure: Data is organized in a tree-like structure with a single root and multiple levels of nested
records.
Example: IBM's Information Management System (IMS).
Characteristics: Fast data retrieval for hierarchical data, but lacks flexibility in handling many-to-many
relationships.

Network DBMS:
Structure: Data is organized in a graph-like structure, allowing multiple parent-child relationships.
Example: Integrated Data Store (IDS), a network DBMS.
Characteristics: More flexible than hierarchical DBMS, supporting many-to-many relationships, but
complex to design and manage.

Relational DBMS (RDBMS):


Structure: Data is organized into tables (relations) with rows and columns.
Example: MySQL, Oracle, SQL Server.
Characteristics: Highly flexible and widely used due to its simplicity, data independence, and powerful
query capabilities using SQL.

Object-Oriented DBMS (OODBMS):


Structure: Data is stored as objects, similar to object-oriented programming.
Example: db4o, ObjectDB.
Characteristics: Supports complex data types and relationships, aligning closely with object-oriented
programming paradigms.

Object-Relational DBMS (ORDBMS):


Structure: Combines features of both relational and object-oriented DBMS.
Example: PostgreSQL.
Characteristics: Provides the flexibility of relational databases with support for complex data types and
objects.

NoSQL DBMS:
Structure: Designed for unstructured or semi-structured data, often not using tables.
Example: MongoDB, Cassandra.
Characteristics: Highly scalable and flexible, suitable for big data and real-time web applications.

2. Classification Based on the Number of Users


Single-User DBMS:
Definition: Supports only one user at a time.
Example: Microsoft Access.
Characteristics: Simple, used for personal or small-scale applications with minimal data.

Multi-User DBMS:
Definition: Supports multiple users concurrently.
Example: MySQL, Oracle.
Characteristics: Suitable for larger organizations, ensuring data consistency and concurrency control.

3. Classification Based on Database Distribution


Centralized DBMS:
Definition: The database is stored and managed in a single location, typically on a central server.
Example: Traditional mainframe databases.
Characteristics: Easier to maintain, but can be a bottleneck and a single point of failure.

Distributed DBMS:
Definition: The database is distributed across multiple locations or servers, connected via a network.
Example: Google Spanner, Apache Cassandra.
Characteristics: Improved reliability and availability, but more complex to manage and ensure
consistency.

Cloud DBMS:
Definition: The database is hosted on a cloud platform, providing scalable and on-demand resources.
Example: Amazon RDS, Google Cloud SQL.
Characteristics: Flexible, scalable, and cost-effective, but dependent on the internet connection and
service provider.

UNIT-II
Introduction of ER Model
Peter Chen developed the ER diagram in 1976. The ER model was created to provide a simple and
understandable model for representing the structure and logic of databases. It has since evolved into
variations such as the Enhanced ER Model and the Object Relationship 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, the ER Diagram is the structural format of the database.

Why Use ER Diagrams In DBMS?


1. ER diagrams represent the E-R model in a database, making them easy to convert into relations
(tables).
2. ER diagrams provide the purpose of real-world modeling of objects which makes them intently
useful.
3. ER diagrams require no technical knowledge and no hardware support.
4. These diagrams are very easy to understand and easy to create even for a naive user.
5. 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 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.

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

What is 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.

What is 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:
We can represent the entity set in ER Diagram but can‟t represent entity in ER Diagram because entity is
row and column in the relation and ER Diagram is graphical representation of data.

Types of Entity
There are two types of entity:
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 can‟t exist 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.

What is 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.
Types of Attributes
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. Ternary Relationship: When there are three entity sets participating in a relationship, the relationship
is called a ternary relationship.

4. N-ary Relationship: When there are n entities set participating in a relationship, the relationship is
called an n-ary relationship.

What is 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
entity and the total number of tables that can be used in this is 2. Let us assume that one surgeon
department can accommodate many doctors. So the Cardinality will be 1 to M. It means one department
has many Doctors.

total number of tables that can used is 3. 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.
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.

Participation Constraint
Participation Constraint is applied to the entity participating in the relationship set.

1. Total Participation – Each entity in the entity set must participate in the relationship. If each student
must enroll in a course, the participation of students will be total. Total participation is shown by a double
line in the ER diagram.

2. Partial Participation – The entity in the entity set may or may NOT participate in the relationship. If
some courses are not enrolled by any of the students, the participation in the course will be partial.
The diagram depicts the „Enrolled in‟ relationship set with Student Entity set having total participation
and Course Entity set having partial participation.

Using Set, it can be represented as,


Every student in the Student Entity set participates in a relationship but there exists a course C4 that is not
taking part in the relationship.

How to Draw ER Diagram?


 The very first step is Identifying all the Entities, and place them in a Rectangle, and labeling them
accordingly.
 The next step is to identify the relationship between them and place them accordingly using the
Diamond, and make sure that, Relationships are not connected to each other.
 Attach attributes to the entities properly.
 Remove redundant entities and relationships.
 Add proper colors to highlight the data present in the database.

You might also like