50% found this document useful (2 votes)
114 views63 pages

R23EM106 (Assignment2)

Uploaded by

Giridharan B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
50% found this document useful (2 votes)
114 views63 pages

R23EM106 (Assignment2)

Uploaded by

Giridharan B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 63

School of Computer Science and Engineering

Assignment – 1

Name of the Course Database Management System


Course Code B22EF0402
Year and Semester II Year (IV Sem)
Academic Year 2024-2025

Submitted By

Name of the Student V Sarvesh


SRN & Section R23EM106 4-B
Name of the Faculty Dr P V Bhaskar Reddy

Max. Marks 05
Marks Signature of Signature of the Faculty
Obtained the Student
Database Management System

Table of Contents

Topic Page no
Various types of data 2
What is database 3
Various disadvantages of File 9
processing
Database Management System 11
Advantages of DBMS 14
Characteristics of Database approach 15
in DBMS
Data Model 16
Schema and instance 21
Database language 24
Various DBMS interfaces 37
Key features of SQL 39
Categories of SQL commands 40
Conceptual Data Model 47
Entity-Relationship (ER) diagram 48
Design the ER diagram 51
Common naming conventions 56
Design issues in DBMS 59
References 62

1
Database Management System

1. Define Data? List and explain the various types of data.

Data refers to raw facts and figures that have no meaning on their own. In a Database
Management System (DBMS), data is collected, stored, and organized so it can be accessed
and used efficiently. When processed and interpreted, data becomes information.

Types of data :

In DBMS, data can be categorized based on its structure and how it is used. Here are the main
types:

a) Structured Data

• Definition: Data that is organized in a fixed format, like rows and columns.

• Example: Data stored in relational databases like MySQL, Oracle, or PostgreSQL.

• Use: Easy to store, retrieve, and manage using SQL.

b) Unstructured Data

• Definition: Data that has no specific format or structure.

• Example: Text files, images, videos, emails, social media posts.

• Use: Stored in NoSQL databases or data lakes; harder to manage with traditional
DBMS.

c) Semi-Structured Data

• Definition: Data that doesn't follow the strict structure of a relational database but still
has some organizational properties (tags, markers).

• Example: XML, JSON files.

• Use: Common in web applications and APIs.

d) Metadata

• Definition: Data about data. It describes other data.

• Example: In a photo, metadata might include file size, resolution, date created, etc.

2
Database Management System

• Use: Helps in organizing and managing data efficiently.

e) Temporal Data

• Definition: Data that represents time-based information.

• Example: Sales records with timestamps, logs.

• Use: Useful in trend analysis, monitoring, or historical comparisons.

2. What is database? Explain the various types of databases.

A database is an organized collection of data stored and accessed electronically. Databases can
store structured, semi-structured, or unstructured data, such as text, images, videos, and files,
making them indispensable for modern applications. They are managed using Database
Management Systems (DBMS), which provide tools for creating, retrieving, and modifying
data.

Key Characteristics of a Database

• Data Organization: Arranges data for easy access and management.

• Efficiency: Provides quick retrieval and updates.

• Scalability: Handles growing amounts of data.

• Security: Protects sensitive information with robust controls.

i. Hierarchical Databases

Hierarchical databases organize data in a tree-like structure where data is arranged


in levels or ranks. Higher-level data serves as a common link for lower-level data, similar to a
hierarchy. For example, in a university, “University” is at the top level, while “Departments”
and “Administration” are at lower levels, even though they are distinct entities.

3
Database Management System

Fig 1: Hierarchical Database Example

This structure can also be viewed as a parent-child relationship, where each parent record can
have multiple child records, but a child record can only have one parent. As more data is added,
the structure expands like a tree. However, hierarchical databases have limitations, such as
being less flexible and harder to scale. Adding new data or elements often requires traversing
the hierarchy, which can be time-consuming.

ii. Network Databases

A network database builds on the hierarchical model but allows child records to link to multiple
parent records, creating a web-like structure of interconnected data. For example, in a
university database, “Students,” “Faculty,” and “Resources” can be linked to both
“Departments” and “Clubs,” forming a flexible, two-directional relationship.

Fig 2: Network Database Example

4
Database Management System

This model is ideal for complex frameworks as it effectively represents many-to-many


relationships. Additionally, its structure simplifies the use of certain database management
languages. However, the downside is that network databases are highly dependent on
their predefined structure, making changes difficult and time-consuming due to their
complexity.

iii. Object-Oriented Databases

Object-oriented databases are based on the principles of object-oriented programming (OOP),


where data is stored as objects. These objects include attributes (data) and methods (functions),
making them easily referenced and manipulated. For instance, a “Person” object in the
database could include attributes like Name and Address and methods
like getLatestAddress() to retrieve information.

Fig 3:Object-Oriented Example

This approach reduces the workload on the database by allowing objects to be reused and
linked directly, streamlining data access and manipulation. Each object behaves as an instance
of the database model, enabling efficient operations.

A practical example of this model is the Berkeley DB software library, which is designed
for fast and efficient query responses in embedded systems. Object-oriented databases are
especially useful for applications involving complex data types or multimedia content.

5
Database Management System

iv. Relational Databases

Considered the most mature of all databases, these databases lead in the production line along
with their management systems. In this database, every piece of information has a relationship
with every other piece of information. This is on account of every data value in the database
having a unique identity in the form of a record.

Note that all data is tabulated in this model. Therefore, every row of data in the database is
linked with another row using a primary key. Similarly, every table is linked with another table
using a foreign key. Refer to the diagram below and notice how the concept of ‘Keys‘ is used
to link two tables.

Fig 4:Relational Database Example

Due to this introduction of tables to organize data, it has become exceedingly popular. In
consequence, they are widely integrated into Web-Ap interfaces to serve as ideal
repositories for user data.

What makes it further interesting in the ease in mastering it, since the language used to interact
with the database is simple (SQL in this case) and easy to comprehend. In Relational databases,
scaling and traversing through data is quite a lightweight task in comparison to Hierarchical
Databases

6
Database Management System

v. Cloud Databases

A cloud database operates in a virtual environment hosted on cloud computing platforms. It is


designed for storing, managing, and executing data over the internet,
providing flexibility and scalability. Cloud databases are widely used for applications
requiring dynamic workloads, as they eliminate the need for on-premises infrastructure.

Common cloud services for accessing and managing databases include SaaS (Software as a
Service) and PaaS (Platform as a Service), which simplify database operations for businesses.
Popular cloud platforms offering database services include:

• Amazon Web Services (AWS)

• Google Cloud Platform (GCP)

• Microsoft Azure

• ScienceSoft, etc.

vi. Centralized Databases

A centralized database is a database stored and managed at a single location, such as a central
server or data center. It ensures higher security and consistency as all data is maintained in one
place, making it easier to control and manage.

Users access the database remotely to fetch or update information. Centralized databases are
commonly used in enterprise systems where data consistency and security are critical.
However, scalability and performance limitations should be carefully considered.

Advantages

• Data Security: Centralized storage makes it easier to implement robust security


measures.

• Reduced Redundancy: Data duplication is minimized, ensuring efficiency.

• Consistency: A single data source ensures uniformity across the system.

Disadvantages

• Response Time: The large size of centralized databases can lead to slower data retrieval
times.

7
Database Management System

• Difficulty in Modifications: Modifying, deleting, or updating data can be challenging


and time-consuming, especially for large datasets.

vii. Personal Databases

A personal database is a small-scale database designed for a single user, typically used on
personal computers or mobile devices. These databases are ideal for managing individual data
like contacts, budgets, notes, or schedules. They are lightweight, easy to use, and
require minimal database administration, making them accessible for non-technical users.

Examples:

• Microsoft Access: A simple database solution for personal or small business needs.

• SQLite: A lightweight, self-contained database commonly used in mobile and desktop


applications.

Advantages:

1. Ease of Use: Simple to set up and manage without requiring advanced technical skills.

2. Low Storage Requirements: Occupies minimal space, making it suitable for smaller
devices.

viii. Operational Databases

An operational database is designed to manage and process real-time data for daily operations
within organizations and businesses. It allows users to create, update, and delete data
efficiently, ensuring that the database reflects current activities and transactions.

Advantages:

1. Easy to Fetch: Data retrieval is quick and efficient, supporting operational tasks.

2. Structured Data: Organizes data systematically for better management and access.

3. Real-Time Processing: Enables immediate updates, ensuring data is always current.

ix. NoSQL Databases

A NoSQL database (short for “non-SQL” or “non-relational”) provides a mechanism


for storing and retrieving data that does not rely on traditional table-based relational models.

8
Database Management System

Instead, it uses flexible data models like key-value pairs, documents, column families,
or graphs, making it ideal for handling unstructured, semi-structured, and structured data.

NoSQL databases are known for their simplicity of design, horizontal scalability (adding more
servers for scaling), and high availability. Unlike relational databases, their data structures
allow faster operations in certain use cases. MongoDB, for instance, is a widely used
document-based NoSQL database.

Advantages

• Easily scales horizontally by adding more servers.

• Can be run on commodity hardware, lowering costs.

• Optimized for large volumes of data and fast queries.

• Handles unstructured, semi-structured, or structured data.

Disadvantages

• NoSQL is an open-source database.

• GUI is not available

• Backup is a weak point for some NoSQL databases like MongoDB.

• Large document size.

3. List the various disadvantages of File processing?


Disadvantages of the Traditional File Systems

The following issues are related to the file-based approach:

• Distinguished and Isolated Data: Imagine a user needs information that is not possible
to be provided using a single file, multiple different files were required, which are
situated in different departments. So all the employees first need to manually and
carefully check each of the files in each department and find the relationship between
them to decipher the information that the user wants.

9
Database Management System

• Data Duplication / Data Redundancy – Due to the manual storing of data, the same data
used to be present in multiple locations using the space in each of the Hard Disk, below
are some following reasons for which Data Redundancy can be a major issue

o Storing the same data multiple times not only wastes resources in every machine
but also is costly to maintain and wastes time.

o Loss of data integrity is another major issue of Data Redundancy, imagine


someone’s address is present in multiple systems and he has applied to update
the address, in one system the address gets updated but in the rest of them it
remains the same, so the if someone from any different department where the
data is not updated tries to send them any letter or something then it would go
to a wrong address.

• Dependence on Data – Files and information were stored in a certain specific format in
files which is hard coded by programmers in languages like C/C++, COBOL, etc. So if
any of the file’s format changes then the programmers need to update the code every
time and the format of every piece of data stored in that file will be changed, which is
a rigorous task for programmers.

• Data representation is challenging from the user’s perspective – The data stored in files
must be represented in such a manner that every user can understand that data clearly
and easily, often it would become hectic as the programmers need to go through
different systems and find the proper connection between data and merge them together
and represent them in a more human-readable format

• Different file types – The file structure would vary based on the programming language
that was used to store them, for example, if a system used COBOL to store certain data
then the structure of that data would differ from the one written in C/C++.

• Data Protection – Data protection was very less due to different reasons like Data
Redundancy, manual storing of data, easy access of confidential data by unauthorized
parties, etc.

• Issues with Transactions – It didn’t follow the ACID (Atomicity, Consistency, Isolation,
and Durability) properties, for that if in the middle of any transaction the system crashed
then it would leave the system in an inconsistent state.

10
Database Management System

• Concurrent issues – Two or more users can view the same file simultaneously, but the
problem arises when they try to update the same file simultaneously.

Database-Based Approach

Keeping in mind the disadvantages of the Traditionally used File Systems, the DBMS was
born. The Database approach nearly solved all the problems faced by traditional file systems
and it also has its own certain advantages which are beneficial for all sizes of organizations in
data storing and data handling.

Importance and Meaning of Data

Data are just structured facts and measurements which are True and construct meaning. Data
is used for many different purposes like calculations, different discussions, proofs, etc. It
doesn’t only include some textual information, data can be numbers, events, certain actions,
etc. Data can be stored in many different places which include –

• Spreadsheets

• Folders

• Lists

• Digital drives like Hard Disk, SSD, Floppy Disk, CD etc

4. Define Database Management System? Explain its types, advantages and


disadvantages and components.

A Database Management System (DBMS) is a software application that interacts with users,
applications, and the database itself to store, manage, and retrieve data efficiently. It provides
tools to define, manipulate, and control access to data while maintaining data consistency,
security, and integrity.

11
Database Management System

Advantages of Database Management System

Database Management System (DBMS) is a collection of interrelated data and a set of software
tools/programs that access, process, and manipulate data. It allows access, retrieval, and use of
that data by considering appropriate security measures. The Database Management system
(DBMS) is really useful for better data integration and security.

Fig 5: Advantages of DBMS

Advantages of Database Management System

The advantages of database management systems are:

1. Data Security: The more accessible and usable the database, the more it is prone to
security issues. As the number of users increases, the data transferring or data sharing
rate also increases thus increasing the risk of data security. It is widely used in the
corporate world where companies invest large amounts of money, time, and effort to
ensure data is secure and used properly. A Database Management System (DBMS)
provides a better platform for data privacy and security policies thus, helping companies
to improve Data Security.

2. 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 how a particular organization is working and also helps to
keep track of how one segment of the company affects another segment.

12
Database Management System

3. 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.

4. 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.

5. Data sharing: A DBMS provides a platform for sharing data across multiple
applications and users, which can increase productivity and collaboration.

6. 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.

7. Data organization: A DBMS provides a systematic approach to organizing data in a


structured way, which makes it easier to retrieve and manage data efficiently.

8. Efficient data access and retrieval: DBMS allows for efficient data access and retrieval
by providing indexing and query optimization techniques that speed up data retrieval.
This reduces the time required to process large volumes of data and increases the overall
performance of the system.

9. Concurrency and maintained Atomicity : That means, if some operation is performed


on one particular table of the database, then the change must be reflected for the entire
database. The DBMS allows concurrent access to multiple users by using the
synchronization technique.

10. Scalability and flexibility: DBMS is highly scalable and can easily accommodate
changes in data volumes and user requirements. DBMS can easily handle large volumes
of data, and can scale up or down depending on the needs of the organization. It
provides flexibility in data storage, retrieval, and manipulation, allowing users to easily
modify the structure and content of the database as needed.

13
Database Management System

5. Illustrate the advantages of DBMS over traditional file-based systems?


Advantages of Database Management System over Traditional File System

1. Better Data Security : DBMS provides a centralized approach to data management that
ensures data integrity and security. To prevent illegal access, alteration, or theft,
database management systems (DBMS) include a number of security features,
including encryption, authentication, and authorization. Sensitive data is safeguarded
against both internal and external attacks thanks to this.

2. Reduced Data Redundancy : DBMS eliminates data redundancy by storing data in a


structured way. It allows sharing data across different applications and users, reducing
the need for duplicating data. By keeping data centrally and offering methods for
sharing and reusing it, database management systems (DBMS) remove data
redundancy. As a result, less data storage is needed, and data consistency is increased.

3. Improved Data Consistency : DBMS allows defining constraints and rules to ensure
that data is consistent and accurate. DBMS ensures data consistency by enforcing data
validation rules and constraints. This ensures that data is accurate and consistent across
different applications and users.

4. Improved Data Access and Availability : DBMS provides efficient data access and
retrieval mechanisms that enable quick and easy data access. It allows multiple users to
access the data simultaneously, ensuring data availability.

5. Improved Data Sharing : DBMS provides a platform for sharing data across different
applications and users. It allows sharing data between different departments and
systems within an organization, improving collaboration and decision-making.
Database Management Systems prevent conflicts and data loss by enabling numerous
people to view and edit the same data at once. This promotes teamwork and enhances
data uniformity throughout the company.

6. Improved Data Integration : DBMS allows integrating data from different sources,
providing a comprehensive view of the data. It enables data integration from different
systems and platforms, improving the quality of data analysis. To avoid data mistakes
and inconsistencies, database management systems (DBMSs) apply data integrity
requirements including referential integrity, entity integrity, and domain integrity. This
guarantees the consistency, accuracy, and completeness of the data.

14
Database Management System

7. Improved Data Backup and Recovery : DBMS provides backup and recovery
mechanisms that ensure data is not lost in case of a system failure. It allows restoring
data to a specific point in time, ensuring data consistency. Database management
systems (DBMS) offer backup and recovery features that let businesses swiftly and
effectively restore lost or damaged data. This guarantees business continuity and lowers
the chance of data loss.

8. Data independence: By separating the logical and physical views of data, database
management systems (DBMS) enable users to work with data without being aware of
its exact location or structure. This offers adaptability and lowers the possibility of data
damage as a result of modifications to the underlying hardware or software.

6. Discuss the Characteristics of Database approach in DBMS.


There are so many characteristics of a database management system, which are as follows –

• A database management system is able to store any kind of data in a database.

• The database management system has to support ACID (atomicity, consistency,


isolation, durability) properties.

• The Database management system allows so many users to access databases at the same
time.

• Backup and recovery are the two main methods which allow users to protect the data
from damage or loss.

• It also provides multiple views for different users in a single organization.

• It follows the concept of normalization which is helpful to minimize the redundancy of


a relation.

• It also provides users query language, helpful to insert, retrieve, update, and delete the
data in a database.

• The characteristics of DBMS are explained below in pictorial form –

15
Database Management System

Fig 6: Characteristics of DBMS

7. Define Data Model? What are the various types of data models used?

Data Models in DBMS

A Data Model in Database Management System (DBMS) is the concept of tools that are
developed to summarize the description of the database. Data Models provide us with a
transparent picture of data which helps us in creating an actual database. It shows us from the
design of the data to its proper implementation of data.

Types of Relational Models

1. Conceptual Data Model

2. Representational Data Model

16
Database Management System

3. Physical Data Model

It is basically classified into 3 types:-

Fig 7: Data Models

6. Conceptual Data Model

The conceptual data model describes the database at a very high level and is useful to
understand the needs or requirements of the database. It is this model, that is used in the
requirement-gathering process i.e. before the Database Designers start making a particular
database. One such popular model is the entity/relationship model (ER model). The E/R model
specializes in entities, relationships, and even attributes that are used by database designers. In
terms of this concept, a discussion can be made even with non-computer science(non-technical)
users and stakeholders, and their requirements can be understood.

Entity-Relationship Model( ER Model): It is a high-level data model which is used to define


the data and the relationships between them. It is basically a conceptual design of any database
which is easy to design the view of data.

Components of ER Model:

1. Entity: An entity is referred to as a real-world object. It can be a name, place, object,


class, etc. These are represented by a rectangle in an ER Diagram.

17
Database Management System

2. Attributes: An attribute can be defined as the description of the entity. These are
represented by Ellipse in an ER Diagram. It can be Age, Roll Number, or Marks for a
Student.

3. Relationship: Relationships are used to define relations among different entities.


Diamonds and Rhombus are used to show Relationships.

Characteristics of a conceptual data model

• Offers Organization-wide coverage of the business concepts.

• This type of Data Models are designed and developed for a business audience.

• The conceptual model is developed independently of hardware specifications like data


storage capacity, location or software specifications like DBMS vendor and technology.
The focus is to represent data as a user will see it in the “real world.”

Conceptual data models known as Domain models create a common vocabulary for all
stakeholders by establishing basic concepts and scope

2. Representational Data Model

This type of data model is used to represent only the logical part of the database and does not
represent the physical structure of the database. The representational data model allows us to
focus primarily, on the design part of the database. A popular representational model is
a Relational model. The relational Model consists of Relational Algebra and Relational
Calculus. In the Relational Model, we basically use tables to represent our data and the
relationships between them. It is a theoretical concept whose practical implementation is done
in Physical Data Model.

The advantage of using a Representational data model is to provide a foundation to form the
base for the Physical model.

Characteristics of Representational Data Model

• Represents the logical structure of the database.

• Relational models like Relational Algebra and Relational Calculus are commonly used.

18
Database Management System

• Uses tables to represent data and relationships.

• Provides a foundation for building the physical data model.

7. Physical Data Model

The physical Data Model is used to practically implement Relational Data Model. Ultimately,
all data in a database is stored physically on a secondary storage device such as discs and tapes.
This is stored in the form of files, records, and certain other data structures. It has all the
information on the format in which the files are present and the structure of the databases, the
presence of external data structures, and their relation to each other. Here, we basically save
tables in memory so they can be accessed efficiently. In order to come up with a good physical
model, we have to work on the relational model in a better way. Structured Query Language
(SQL) is used to practically implement Relational Algebra.

This Data Model describes HOW the system will be implemented using a specific DBMS
system. This model is typically created by DBA and developers. The purpose is actual
implementation of the database.

Characteristics of a physical data model:

• The physical data model describes data need for a single project or application though
it maybe integrated with other physical data models based on project scope.

• Data Model contains relationships between tables that which addresses cardinality and
nullability of the relationships.

• Developed for a specific version of a DBMS, location, data storage or technology to be


used in the project.

• Columns should have exact datatypes, lengths assigned and default values.

• Primary and Foreign keys, views, indexes, access profiles, and authorizations, etc. are
defined

Some Other Data Models

8. Hierarchical Model

The hierarchical Model is one of the oldest models in the data model which was developed by
IBM, in the 1950s. In a hierarchical model, data are viewed as a collection of tables, or we can
say segments that form a hierarchical relation. In this, the data is organized into a tree-like
19
Database Management System

structure where each record consists of one parent record and many children. Even if the
segments are connected as a chain-like structure by logical associations, then the instant
structure can be a fan structure with multiple branches. We call the illogical associations as
directional associations.

2. Network Model

The Network Model was formalized by the Database Task group in the 1960s. This model is
the generalization of the hierarchical model. This model can consist of multiple parent
segments and these segments are grouped as levels but there exists a logical association
between the segments belonging to any level. Mostly, there exists a many-to-many logical
association between any of the two segments.

9. Object-Oriented Data Model

In the Object-Oriented Data Model, data and their relationships are contained in a single
structure which is referred to as an object in this data model. In this, real-world problems are
represented as objects with different attributes. All objects have multiple relationships between
them. Basically, it is a combination of Object Oriented programming and a Relational Database
Model.

10. Float Data Model

The float data model basically consists of a two-dimensional array of data models that do not
contain any duplicate elements in the array. This data model has one drawback it cannot store
a large amount of data that is the tables can not be of large size.

11. Context Data Model

The Context data model is simply a data model which consists of more than one data model.
For example, the Context data model consists of ER Model, Object-Oriented Data Model, etc.
This model allows users to do more than one thing which each individual data model can do.

6. Semi-Structured Data Model

Semi-Structured data models deal with the data in a flexible way. Some entities may have extra
attributes and some entities may have some missing attributes. Basically, you can represent
data here in a flexible way.

20
Database Management System

Advantages of Data Models

1. Data Models help us in representing data accurately.

2. It helps us in finding the missing data and also in minimizing Data Redundancy.

3. Data Model provides data security in a better way.

4. The data model should be detailed enough to be used for building the physical database.

5. The information in the data model can be used for defining the relationship between
tables, primary and foreign keys, and stored procedures.

Disadvantages of Data Models

1. In the case of a vast database, sometimes it becomes difficult to understand the data
model.

2. You must have the proper knowledge of SQL to use physical models.

3. Even smaller change made in structure require modification in the entire application.

4. There is no set data manipulation language in DBMS.

5. To develop Data model one should know physical data stored characteristics.

8. What is schema and instance? Write the differences.


What is Schema?

Schema is the overall description of the database. The basic structure of how the data will be
stored in the database is called schema. In DBMS, the term schema refers to the architecture
of the database which describes how it will appear or will be constructed. It describes the
organization of data such as tables, relationships as well as constraints. A schema is a template
that dictates how data items in a database will be stored, arranged, and accessed.

21
Database Management System

Fig 8: Schema

Schema is of three types: Logical Schema, Physical Schema and view Schema.

• Logical Schema – It describes the database designed at a logical level.

• Physical Schema – It describes the database designed at the physical level.

• View Schema – It defines the design of the database at the view level.

Example:

Let’s say a table teacher in our database named school, the teacher table requires the name,
dob, and doj in their table so we design a structure as:

Teacher table
name: String
doj: date
dob: date

Advantages of Schema

22
Database Management System

• Consistency: Guarantees proper storage of data in order to allow easy access and
expandability.

• Structure: Helps in easy arrangement of the data base in an organized manner and hence
makes it easy to comprehend.

• Data Integrity: Puts in place restrictions that ensure the data’s maintaining of its
accuracy and subsequent reliability.

Disadvantages of Schema

• Rigidity: Schemas, defined, may be rigid for alteration, and may take a huge amount of
effort in order to alter the scheme.

• Complexity: Developing a schema may be difficult or time consuming in case of large


databases.

What is Instance?

An instance of DBMS refers to real data in a database coming at some particular point in time.
Instance on the other hand refers to the content in the database in as much as it refers to the
structure defined under a particular schema at a given point.

Example

Let’s say a table teacher in our database whose name is School, suppose the table has 50 records
so the instance of the database has 50 records for now and tomorrow we are going to add
another fifty records so tomorrow the instance has a total of 100 records. This is called an
instance.

Advantages of Instance

• Real-Time Representation: It a return of the data in the database at a certain point in


time as may be required for analysis or for performing operations.

• Flexibility: While a schema remains fixed in time, instances can be quite volatile, as
data is written, updated, or deleted.

Disadvantages of Instance

• Volatility: Those are occurrences may be dynamic in a way they are different over time
and this may make it a challenge to keep track without the necessary intervention.

23
Database Management System

• Data Integrity Issues: If not well regulated, it is evident that the data in an instance could
become very inconsistent and at times even incorrect.

Fig 9:Difference between Schema and Instance

9. What is a database language, and why is it important in the context of


database management systems?
Databases are essential for efficiently storing, managing, and retrieving large volumes of data.
They utilize both software and hardware components. The software provides an interface that
enables users or applications to interact with the database, while the hardware consists of
servers and storage systems responsible for physically storing and organizing the data, either
in memory or on physical devices like hard drives.

In this article, we will explore the types of database languages used in a Database Management
System (DBMS). These languages are crucial for performing operations such as data
creation, manipulation, retrieval, and management. They provide the tools necessary to define,
control, and manipulate the data effectively.

What is a Database?

24
Database Management System

A database is a structured collection of data stored electronically. It allows users to


easily access, manage, and update data. For example, a phone contact list on our smartphone
is a small database. It keeps track of names, phone numbers, and addresses, allowing us to
search and access this information quickly when needed. Databases are widely used in
businesses, websites, and applications to store and manage large volumes of data efficiently.

A Database Management System (DBMS) is the software that interacts with the database,
providing an interface to users and applications. It ensures the efficient storage and retrieval of
data, maintains data integrity, and provides security features like access control and
authentication.

Types of Database Languages in DBMS

Database languages are specialized languages used to interact with a database. They allow users
to perform different tasks such as defining, controlling, and manipulating the data. There are
several types of database languages in DBMS, categorized into the following four main types:

1. DDL (Data Definition Language)

2. DCL (Data Control Language)

3. DML (Data Manipulation Language)

4. TCL (Transaction Control Language)

Each category serves a different purpose within the database management process. Let’s break
down each one.

fig 10: Type of Database Language

25
Database Management System

1. DDL (Data Definition Language)

The DDL stands for Data Definition Language, Which is used to define the database’s internal
structure and Pattern of the Database. It is used to define and modify the structure of the
database itself, including the tables, views, indexes, and other schema-related objects. It deals
with the creation and modification of database schema, but it doesn’t deal with the data itself.

Following are the five DDL commands in SQL:

• CREATE: Used to create database objects like tables, indexes, or views.

• ALTER: Used to modify the structure of an existing database object, such as adding a
new column to a table.

• DROP: Used to delete database objects.

• TRUNCATE: Used to remove all rows from a table, without affecting the structure.

• RENAME: Used to change the name of a database object.

Now we will explain each command with examples for better understanding of the concepts.

CREATE Command

The CREATE is a DDL command used to create databases, tables, triggers and other database
objects.

Syntax

CREATE TABLE Students (


column1 INT,
column2 VARCHAR(50),
column3 INT
);

Example:

26
Database Management System

fig 11: Create table

Alter Command

ALTER is a DDL command which changes or modifies the existing structure of the database,
and it also changes the schema of database objects. We can also add and drop constraints of the
table using the ALTER command.

Syntax

ALTER TABLE Students ADD column_name;

Example:

fig 12: Alter command

27
Database Management System

Drop Command

DROP is a DDL command used to delete/remove the database objects from the SQL database.
We can easily remove the entire table, view, or index from the database using this DDL
command.

Syntax

DROP Table Table_name;

Example:

Fig 13: Drop

Truncate Command

The TRUNCATE command is used to delete all the records from a table without removing the
structure. Unlike the DELETE command, which can remove specific rows and can be rolled
back, TRUNCATE is a more efficient way to delete all rows in a table without logging
individual row deletions.

Syntax

TRUNCATE TABLE table_name;

Example:

Fig 14: Truncate

28
Database Management System

Rename Command

The RENAME command in a Database Management System (DBMS) is used to change the
name of a database object, such as a table, column, or index. This command is helpful when
we want to give a more meaningful or appropriate name to an object without needing to recreate
it.

Syntax:

ALTER TABLE Old_Table_Name RENAME TO New_Table_Name;

Example:

Fig 15: Rename

DCL (Data Control Language)

DCL stands for Data Control Language. It is used to control the access permissions of users to
the database. DCL commands help grant or revoke privileges to users, determining who can
perform actions like reading or modifying data. DCL commands are transactional, meaning
they can be rolled back if necessary.

The two main DCL commands are:

• Grant: Gives user access to the database

• Revoke: Removes access or permissions from the user

Now we will explain these commands with proper examples for better understanding

Grant Command

The GRANT command in a Database Management System (DBMS) is used to provide


specific permissions or privileges to users or roles. This command allows administrators to
control access to database objects, ensuring that only authorized users can perform certain
actions, such as selecting, inserting, updating, or deleting data.

29
Database Management System

Syntax

GRANT privileges
ON object
TO user_or_role [WITH GRANT OPTION];

Example:

GRANT SELECT, INSERT ON students TO user;

Revoke Command

The REVOKE command in a Database Management System (DBMS) is used to remove


previously granted permissions or privileges from users or roles. This command is essential
for managing access control, ensuring that users do not have more privileges than necessary to
perform their tasks.

Syntax

REVOKE privileges ON object FROM user_or_role;

Example

REVOKE ALL PRIVILEGES ON students FROM user;

DML (Data Manipulation Language)

The DML (Data Manipulation Language) is used toto manage and manipulate data within a
database. With DML, you can perform various operations such as inserting, updating, selecting,
and deleting data. These operations allow you to work with the actual content in your database
tables.

Here are the key DML commands:

• SELECT: Retrieves data from the table based on specific criteria.

• INSERT: Adds new rows of data into an existing table.

• UPDATE: Modifies existing data in a table.

• DELETE: Removes data from a table.

• MERGE: Performs an "upsert" operation, which means updating existing records or


inserting new ones if they don’t exist.

30
Database Management System

• CALL: Executes stored procedures or functions.

• LOCK TABLE: Prevents other users from accessing the table while changes are being
made.

Now, we will explain these commands with examples for better understanding:

SELECT Command

The SELECT command in SQL (Structured Query Language) is used to retrieve data from one
or more tables in a database. It is the most commonly used commands in SQL, allowing users
to specify which columns and rows of data they want to retrieve and how they want that data
organized. The SELECT statement can be used in various ways, such as selecting all data from
a table, filtering records based on conditions, or sorting the results.

Syntax

SELECT * FROM Table_Name

Example:

Fig 16: Select Command

Insert Command

The INSERT command in SQL (Structured Query Language) is used to add new records or
rows to a table in a database. It is a key operation in database management, essential for
populating tables with new data. This command can insert data into all columns or specific
columns of a table.

Syntax

INSERT INTO Table_Name (Column 1, Column 2, Column 3, Column 4) VALUES (Value 1,


Value 2,Value 3, Value 4);

31
Database Management System

Example:

fig 17: Insert command

Update Command

The UPDATE command in SQL (Structured Query Language) is used to modify existing
records in a table. This command enables users to change the values of one or more columns
for specific rows based on a condition (criteria). It is crucial for maintaining and adjusting data
in a database when necessary.

Syntax

UPDATE Table_Name SET Name = 'New_Value' WHERE Name = 'Ola_Value';

Example:

Fig 18: Update

32
Database Management System

Delete Command

The DELETE command in SQL (Structured Query Language) is used to remove one or more
existing records from a table in a database. It is an essential operation for managing data,
enabling users to delete specific rows that meet certain conditions or criteria.

Syntax:

DELETE FROM Table_Name WHERE Column = Value;

Example:

Fig 19: Delete Command

Merge Command

The Merge command in SQL is used to perform an upsert operation, which combines
both UPDATE and INSERT actions. It allows you to insert new rows if they do not exist, or
update existing rows if they match a certain condition. This command is particularly useful for
synchronizing two tables by inserting new records and updating existing ones in a single
operation.

Syntax:

MERGE INTO target_table AS target


USING source_table AS source
ON (target.id = source.id)
WHEN MATCHED THEN
UPDATE SET target.name = source.name

33
Database Management System

WHEN NOT MATCHED THEN


INSERT (id, name) VALUES (source.id, source.name);

Example:

MERGE INTO Employees AS target


USING New_Hires AS source
ON target.EmployeeID = source.EmployeeID
WHEN MATCHED THEN
UPDATE SET target.Name = source.Name, target.Salary = source.Salary
WHEN NOT MATCHED THEN
INSERT (EmployeeID, Name, Salary)
VALUES (source.EmployeeID, source.Name, source.Salary);

Table 1. Employees Table (Before Merge):

fig 20: Employee Table

Table 2: New_Hires Table:

fig 21: New_Hires Table

Output

fig 22: Employee Table (After Merge)

34
Database Management System

CALL Command

The Call command is used to invoke a stored procedure or user-defined function, which is a
set of precompiled SQL statements. It allows you to execute complex operations within a
database as a single unit.

Syntax:

CALL user_defined_function(parameter 1, parameter 2);

Example:

CALL UpdateEmployeeSalary(101, 55000);

LOCK TABLE

The lock table command is used to lock the table for preventing access from others, ensuring
no other operations (like insertions, updates, or deletions) can be performed on the table while
it's locked. Useful for transactional operations where consistency is important.

Syntax:

LOCK TABLE your_table IN EXCLUSIVE MODE;

Example:

LOCK TABLE ClassMembers IN EXCLUSIVE MODE;

TCL ( Transaction Control Language )

The TCL full form is Transaction Control Language commands are used to manage and control
transactions in a database, grouping them into logical units. These commands help ensure the
integrity of data and consistency during complex operations. Here are the two main commands
in this category:

• Commit: Saves all the changes made during the current transaction to the database.
These are very useful in the banking sector.

• Rollback: used to restore the database to its original state from the last commit. This
command also plays an important role in Banking Sectors.

Now we will explain these two commands for better understanding with examples

35
Database Management System

Commit Command

The COMMIT command is used to save all changes made during a transaction in the database.
This command ensures that modifications made by DML statements (such as INSERT,
UPDATE, or DELETE) become permanent in the database.

Syntax

Database Operation
Commit

Example:

fig 23: commit

ROLLBACK Command

The rollback command is used to restore the database to its state at the last COMMIT,
effectively undoing any changes made since that point. It helps ensure data consistency by
allowing the reversal of partial or erroneous operations.

Syntax

ROLLBACK;

Example:

Fig 24: rollback

36
Database Management System

Conclusion

In conclusion, database languages play a crucial role in managing and manipulating data in a
database management system (DBMS). There are different type of database language
like DDL, DCL, DML, and TCL. The DDL language is used for used for defining the
database's internal structure and Pattern of the Database. The DCL commands are used to
control the data from the user means They can provide control of the Database, Table, and Data.
The DML commands are used to manipulate the Data in the Table like Inserting, updating, and
deleting the Data finally the TCL commands are used to save and restore the previous state of
the Database.

10.List the various DBMS interfaces and explain briefly.


DBMS Interfaces

A Database Management System (DBMS) interface is the medium through which users interact
with a database without needing to write complex queries directly in a query language like
SQL. These interfaces are designed to simplify database operations and make them more user-
friendly.

1. Menu-Based Interfaces

• Description: Present users with a list of options or menus to guide them in forming
database queries.

• Benefits: No need to remember command syntax; step-by-step query creation.

• Example: Pull-down menus in web apps or browsing interfaces.

2. Forms-Based Interfaces

• Description: Display a form where users input data in predefined fields.

• Function: Used to insert or retrieve data based on filled entries.

• Designed for: Users with little or no technical knowledge.

37
Database Management System

• Example: SQL Forms.

3. Graphical User Interface (GUI)

• Description: Displays database schema visually (e.g., diagram form) and lets users
interact with it.

• Tools: Combines forms and menus with mouse-driven interactions.

• Usage: Widely used in modern DBMS tools like MySQL Workbench, Oracle SQL
Developer.

4. Natural Language Interfaces

• Description: Accept user input in natural language (e.g., English) and interpret it to
generate database queries.

• Process:

o Refers to its internal schema and dictionary.

o Converts user request to a structured query.

• Limitation: Limited capabilities in understanding complex or ambiguous queries.

5. Speech Input and Output Interfaces

• Description: Allow voice-based queries and responses.

• Use Cases: Telephone directories, flight info systems, banking services.

• Functionality: Speech recognition for query input and speech synthesis for output.

6. Interfaces for Parametric Users

• Description: Interfaces with limited commands optimized for repetitive tasks.

• Users: Often used by clerical staff (e.g., bank employees).

38
Database Management System

• Example: Money transfer, account updates.

7. Interfaces for Database Administrators (DBAs)

• Description: Special interfaces with privileged commands for managing the database
system.

• Functions:

o Account creation

o System configuration

o Schema modification

o Storage management

o Authorization control

11.What are the key features of SQL, and how does it facilitate database
operations?

Here are some key features of Structured Query Language (SQL):

1. Data Definition Language (DDL): SQL provides a set of commands to define and
modify the structure of a database, including creating tables, modifying table structure,
and dropping tables.

2. Data Manipulation Language (DML): SQL provides a set of commands to manipulate


data within a database, including adding, modifying, and deleting data.

3. Query Language: SQL provides a rich set of commands for querying a database to
retrieve data, including the ability to filter, sort, group, and join data from multiple
tables.

4. Transaction Control: SQL supports transaction processing, which allows users to group
a set of database operations into a single transaction that can be rolled back in case of
failure.

39
Database Management System

5. Data Integrity: SQL includes features to enforce data integrity, such as the ability to
specify constraints on the values that can be inserted or updated in a table, and to
enforce referential integrity between tables.

6. User Access Control: SQL provides mechanisms to control user access to a database,
including the ability to grant and revoke privileges to perform certain operations on the
database.

7. Portability: SQL is a standardized language, meaning that SQL code written for one
database management system can be used on another system with minimal
modification.

12.Describe the main categories of SQL commands and provide examples for
each with proper syntax.
What are SQL Commands?

SQL Commands are like instructions to a table. It is used to interact with the database with
some operations. It is also used to perform specific tasks, functions, and queries of data. SQL
can perform various tasks like creating a table, adding data to tables, dropping the table,
modifying the table, set permission for users.

SQL Commands are mainly categorized into five categories:

• DDL – Data Definition Language

• DQL – Data Query Language

• DML – Data Manipulation Language

• DCL – Data Control Language

• TCL – Transaction Control Language

40
Database Management System

Fig 24:SQL Commands

1. Data Definition Language (DDL) in SQL

DDL or Data Definition Language actually consists of the SQL commands that can be used
to defining, altering, and deleting database structures such as tables, indexes, and schemas. It
simply deals with descriptions of the database schema and is used to create and modify the
structure of database objects in the database

Common DDL Commands

Command Description Syntax

Create database or its


CREATE TABLE table_name
objects (table, index,
CREATE (column1 data_type, column2
function, views, store
data_type, ...);
procedure, and triggers)

41
Database Management System

Command Description Syntax

Delete objects from the


DROP DROP TABLE table_name;
database

Alter the structure of the ALTER TABLE table_name ADD


ALTER
database COLUMN column_name data_type;

Remove all records from


a table, including all
TRUNCATE TRUNCATE TABLE table_name;
spaces allocated for the
records are removed

Add comments to the COMMENT 'comment_text' ON


COMMENT
data dictionary TABLE table_name;

Rename an object RENAME TABLE old_table_name


RENAME
existing in the database TO new_table_name;

Fig 25: Description and Syntax of DDL commands

Example of DDL

CREATE TABLE employees (


employee_id INT PRIMARY KEY,
first_name VARCHAR(50),
last_name VARCHAR(50),
hire_date DATE
);

In this example, a new table called employees is created with columns for employee ID, first
name, last name, and hire date.

2. Data Query Language (DQL) in SQL

42
Database Management System

DQL statements are used for performing queries on the data within schema objects. The
purpose of the DQL Command is to get some schema relation based on the query passed to
it. This command allows getting the data out of the database to perform operations with it.
When a SELECT is fired against a table or tables the result is compiled into a further temporary
table, which is displayed or perhaps received by the program.

DQL Command

Command Description Syntax

It is used to retrieve data from SELECT column1, column2, ...FROM


SELECT
the database table_name WHERE condition;

Fig 26: Description and Syntax of DQL commands

Example of DQL

SELECT first_name, last_name, hire_date


FROM employees
WHERE department = 'Sales'
ORDER BY hire_date DESC;

This query retrieves employees’ first and last names, along with their hire dates, from the
employees table, specifically for those in the ‘Sales’ department, sorted by hire date.

3. Data Manipulation Language (DML) in SQL

The SQL commands that deal 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.

Common DML Commands

43
Database Management System

Command Description Syntax

Insert data into a INSERT INTO table_name (column1, column2, ...)


INSERT
table VALUES (value1, value2, ...);

Update existing UPDATE table_name SET column1 = value1,


UPDATE
data within a table column2 = value2 WHERE condition;

Delete records from


DELETE DELETE FROM table_name WHERE condition;
a database table

Table control
LOCK LOCK TABLE table_name IN lock_mode;
concurrency

Call a PL/SQL or
CALL CALL procedure_name(arguments);
JAVA subprogram

EXPLAIN Describe the access EXPLAIN PLAN FOR SELECT * FROM


PLAN path to data table_name;

Fig 27: Description and Syntax of DML commands

Example of DML

INSERT INTO employees (first_name, last_name, department)


VALUES ('Jane', 'Smith', 'HR');

This query inserts a new record into the employees table with the first name ‘Jane’, last name
‘Smith’, and department ‘HR’.

4. Data Control Language (DCL) in SQL

DCL (Data Control Language) includes commands such as GRANT and REVOKE which
mainly deal with the rights, permissions, and other controls of the database system. These

44
Database Management System

commands are used to control access to data in the database by granting or revoking
permissions.

Common DCL Commands

Command Description Syntax

Assigns new privileges


to a user account, GRANT privilege_type
allowing access to [(column_list)] ON [object_type]
GRANT
specific database object_name TO user [WITH
objects, actions, or GRANT OPTION];
functions.

Removes previously
REVOKE [GRANT OPTION
granted privileges from
FOR] privilege_type
a user account, taking
REVOKE [(column_list)] ON [object_type]
away their access to
object_name FROM user
certain database objects
[CASCADE];
or actions.

Fig 27: Description and Syntax of DCL commands

Example of DCL

GRANT SELECT, UPDATE ON employees TO user_name;

This command grants the user user_name the permissions to select and update records in the
employees table.

5. Transaction Control Language (TCL) in SQL

Transactions group a set of tasks into a single execution unit. Each transaction begins with a
specific task and ends when all the tasks in the group are successfully completed. If any of
the tasks fail, the transaction fails. Therefore, a transaction has only two
results: success or failure. We can explore more about transactions here.

45
Database Management System

Common TCL Commands

Command Description Syntax

BEGIN BEGIN TRANSACTION


Starts a new transaction
TRANSACTION [transaction_name];

Saves all changes made


COMMIT COMMIT;
during the transaction

Undoes all changes made


ROLLBACK ROLLBACK;
during the transaction

Creates a savepoint within the


SAVEPOINT SAVEPOINT savepoint_name;
current transaction

Fig 28: Description and Syntax of TCL commands

Example of TCL

BEGIN TRANSACTION;
UPDATE employees SET department = ‘Marketing’ WHERE department = ‘Sales’;
SAVEPOINT before_update;
UPDATE employees SET department = ‘IT’ WHERE department = ‘HR’;
ROLLBACK TO SAVEPOINT before_update;
COMMIT;

In this example, a transaction is started, changes are made, and a savepoint is set. If needed,
the transaction can be rolled back to the savepoint before being committed.

Important SQL Commands

1. SELECT: Used to retrieve data from a database.

2. INSERT: Used to add new data to a database.

3. UPDATE: Used to modify existing data in a database.

46
Database Management System

4. DELETE: Used to remove data from a database.

5. CREATE TABLE: Used to create a new table in a database.

6. ALTER TABLE: Used to modify the structure of an existing table.

7. DROP TABLE: Used to delete an entire table from a database.

8. WHERE: Used to filter rows based on a specified condition.

9. ORDER BY: Used to sort the result set in ascending or descending order.

10. JOIN: Used to combine rows from two or more tables based on a related column
between them.

13. Define the Conceptual Data Model (CDM)? Explain high-level conceptual data
models for database design.
Conceptual database design is the process of identifying the essential data elements,
relationships, and constraints in a data model, which represents a particular organization’s
business requirements. The conceptual design stage is the first step in the database design
process, which precedes the logical and physical design stages. In this article, we will discuss
the conceptual database design, its objectives, its process, and the key components of a
conceptual data model.

Fig 29: Objectives of Conceptual Database Design

47
Database Management System

The primary objective of conceptual database design is to create a high-level data model that
reflects the business requirements and provides a clear understanding of the data elements,
relationships, and constraints involved. This data model serves as a blueprint for the logical
and physical database design stages.

The key objectives of conceptual database design are as follows :

• Identify the entities and their attributes :Entities are objects or concepts that exist in the
real world and can be distinguished from each other. Attributes are the properties or
characteristics of the entities. The first objective of conceptual database design is to
identify the entities and their attributes that are relevant to the organization’s business
requirements.

• Define the relationships : Relationships are the associations between entities. The
second objective of conceptual database design is to define the relationships between
the identified entities. Relationships can be one-to-one, one-to-many, or many-to-many.

• Establish the constraints :Constraints are the rules that govern the relationships between
entities. The third objective of conceptual database design is to establish the constraints
between entities, which ensure data consistency and integrity.

14.What is an Entity-Relationship (ER) diagram and ER Model? What is its


primary purpose in database design? Describe the various components of
an ER diagram with suitable notation?
We typically follow the below steps for designing a database for an application.

• Gather the requirements (functional and data) by asking questions to the database users.

• Do a logical or conceptual design of the database. This is where ER model plays a role.
It is the most used graphical representation of the conceptual design of a database.

• Physical Database Design (Like indexing) and external design (like views)

The Entity Relationship Model is a model for identifying entities (like student, car or company)
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.

48
Database Management System

Why Use ER Diagrams In DBMS?

• ER diagrams represent the E-R model in a database, making them easy to convert into
relations (tables).

• ER diagrams provide the purpose of real-world 49odelling of objects which makes them
intently useful.

• ER diagrams require no technical knowledge of the underlying DBMS used.

• 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.

Fig 30: Symbols used in ER Diagram

49
Database Management System

Components of ER Diagram

ER Model consists of Entities, Attributes, and Relationships among Entities in a Database


System.

Fig 31: Components of ER Diagram

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:

Fig 32: Entity Set

50
Database Management System

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:

i. 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.

ii. 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.

15.Design the ER diagram and create Schema for the following:

i. University Database:

Entities: Student, Course, Professor, Department

Attributes: StudentID, StudentName, CourseID, CourseName, ProfessorID, ProfessorName,


DepartmentID, DepartmentName

Relationships: Enroll (between Student and Course), Teaches (between Professor and Course),
BelongsTo (between Student and Department)

51
Database Management System

Fig 33: ER Diagram for University Database:

ii. Hospital Management Systems:


Entities: Patient, Doctor, Nurse, Department, Appointment
Attributes: PatientID, PatientName, DoctorID, DoctorName, NurseID,
NurseName, DepartmentID, DepartmentName, AppointmentID,
AppointmentDateTime
Relationships: Treats (between Doctor and Patient), Assigned (between Nurse
and Department), WorksIn (between Doctor/Nurse and Department), Attends
(between Patient and Appointment)

Fig 34: ER Diagram for Hospital Management Systems

52
Database Management System

iii. Library Management System:


Entities: Book, Author, Member, Loan
Attributes: BookID, Title, AuthorID, AuthorName, MemberID, MemberName,
LoanID, LoanDate, DueDate
Relationships: WrittenBy (between Book and Author), BorrowedBy (between
Member and Book), Issued (between Member and Loan)

Fig 35: ER Diagram for Library Management System

iv. Online Shopping System:


Entities: Customer, Product, Order, Payment
Attributes: CustomerID, CustomerName, ProductID, ProductName, OrderID,
OrderDate, PaymentID, PaymentAmount
Relationships: Places (between Customer and Order), Contains (between Order
and Product), Pays (between Customer and Payment)

53
Database Management System

Fig 36: ER Diagram for Online Shopping System

v. Social Media Platform:


Entities: User, Post, Comment, Like
Attributes: UserID, UserName, PostID, PostContent, CommentID,
CommentContent, LikeID, LikeTimestampAttributes: UserID, UserName,
PostID, PostContent, CommentID, CommentContent, LikeID, LikeTimestamp
Relationships: Posts (between User and Post), CommentsOn (between User and
Comment), Likes (between User and Like)

54
Database Management System

Fig 37: ER Diagram for Social Media Platform


vi. Banking System:
Entities: Account, Customer, Transaction, Branch
Attributes: AccountNumber, CustomerID, CustomerName, TransactionID,
TransactionAmount, BranchID, BranchLocation
Relationships: Owns (between Customer and Account), Transacts (between
Account and Transaction), LocatedAt (between Branch and Account)

Fig 38: ER Diagram for Banking System

55
Database Management System

16.What are some common naming conventions used for tables, columns,
indexes, and constraints in a database? and why are they important?
It is essential to name databases, tables, and columns appropriately when developing a database
for readability, maintainability, and efficient communication between developers and users.
Consistent naming standards facilitate cooperation and increase comprehension of the database
structure. In order to maintain clarity and consistency, we will go over the recommended
practices for naming databases, tables, and columns in this post.

• Database naming conventions :

The most advanced container for arranging related data is a database. Think about the following
recommended practices when naming databases .

o Use names that are meaningful and descriptive : Pick a name that accurately
describes the database's domain or purpose. Abbreviations that are difficult to
grasp should be avoided, such as "Database 1" or other generic names. A human
resources system's database, for instance, may be called "HRDB."

o Lowercase letters : To increase readability and prevent potential difficulties with


case sensitivity in certain database systems, use lowercase letters for database
names

o Separate words with underscores or capitalization : Use underscores or


uppercase to separate terms in database names if there are many words; this will
make the name easier to understand. A preferable option to "customer data" is,
for instance, "customer_data" or "Customer Data."

o Maintain consistency across databases : If your system has many databases,


keep your naming conventions consistent to make maintenance and
understanding easier.

Examples

-- Example of creating a database with a meaningful name

CREATE DATABASE HRDB;

-- Example of using lowercase letters for a database name

56
Database Management System

CREATE DATABASE hrdb;

-- Example of using underscores to separate words in a database name

CREATE DATABASE customer_data;

Advertisement

PauseSkip backward 5 secondsSkip forward 5 seconds

Mute

Fullscreen

Output of the commands in same order

Database created : HRDB

Database created : hrdb

Database created : customer_data

• Table Naming Conventions :

A table is a grouping of linked data items. Understanding the data that tables contain depends
on their proper name. Think about the following suggestions

o Use singular nouns : Singular nouns should be used, as they identify distinct
items in table names. For instance, substitute "customer" for "customers

o Be precise and descriptive : Pick titles that accurately convey the table's purpose
or content. Avoid using names that are vague or general. As an illustration, use
"order_details" rather than "data" or "table 1."

o Capitalize or use uppercase letters : To make a table name easier to read,


capitalize or use uppercase letters for each word's first letter. As an illustration,
"Order Details" or "ORDER_DETAILS."

57
Database Management System

o Keep reserved terms out of table names : Check to see whether the database
system you're using has any reserved words or keywords. Use of database-
specific reserved terms should be avoided at all costs.

o Use underscores to separate words in multi-word names : To make table names


easier to understand, use underscores when there are many words in a name. As
an illustration, "customer_orders" or "Customer_Orders."

Examples

-- Example of creating a table with a singular noun name

CREATE TABLE customer (

customer_id INT,

first_name VARCHAR(50),

last_name VARCHAR(50)

);

-- Example of using uppercase letters for each word in a table name

CREATE TABLE OrderDetails (

order_id INT,

product_id INT,

quantity INT

);

-- Example of using underscores to separate words in a table name

CREATE TABLE customer_orders (

order_id INT,

58
Database Management System

customer_id INT,

order_date DATE);

17.What are the primary considerations when designing the schema for a new
database? Write short notes on design issues in DBMS.

1. Requirements Analysis

o Understand what the system needs to store and process.

o Identify data entities, attributes, and relationships.

2. Data Integrity

o Ensure data correctness using constraints (e.g., PRIMARY KEY, FOREIGN


KEY, UNIQUE).

o Maintain consistency with validation rules.

3. Normalization

o Eliminate redundancy and ensure efficient storage using normalization (1NF,


2NF, 3NF).

o Helps reduce data anomalies.

4. Data Types and Sizes

o Choose appropriate data types for attributes (e.g., VARCHAR, INT).

o Optimize storage and performance.

5. Scalability

o Design with future growth in mind (more users, more data).

o Use indexing and partitioning strategies.

6. Security

o Define user roles and access privileges.

59
Database Management System

o Protect sensitive data with encryption and access control.

7. Performance

o Optimize for query speed using indexes, denormalization (when needed), and
caching.

o Consider read/write frequency for different entities.

8. Relationships

o Carefully map relationships (1:1, 1:M, M:N) using foreign keys or bridge tables.

9. Backup and Recovery

o Include support for regular data backup and quick recovery mechanisms.

10. Business Rules

• Implement specific rules relevant to the organization (e.g., constraints, triggers).

Design Issues in DBMS (Short Notes)

1. Redundancy and Inconsistency

o Redundant data leads to inconsistency.

o Normalization helps minimize this issue.

2. Handling Null Values

o Schema should account for optional fields.

o Too many nulls can waste space and complicate queries.

3. Data Integrity

o Enforcing entity, referential, and domain integrity ensures valid data entry.

4. Entity-Relationship Mapping

o Converting ER diagrams to relational schemas can be complex.

o Special care is needed for M:N relationships and weak entities.

5. Normalization vs. Performance


60
Database Management System

o While normalization improves structure, too much normalization can hurt


performance.

o Denormalization may be used for read-heavy systems.

6. Schema Evolution

o The design must allow for changes over time without breaking existing
functionality.

o Use version control and migration tools.

****************************************

61
Database Management System

References
• GeeksforGeeks | A computer science portal for geeks
• Tutorials on Technical and Non Technical Subjects
• https://www.scaler.com/
• https://google.com/

62

You might also like