R23EM106 (Assignment2)
R23EM106 (Assignment2)
Assignment – 1
Submitted By
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
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.
b) Unstructured Data
• 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).
d) Metadata
• Example: In a photo, metadata might include file size, resolution, date created, etc.
2
Database Management System
e) Temporal Data
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.
i. Hierarchical Databases
3
Database Management System
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.
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.
4
Database Management System
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
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.
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
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:
• Microsoft Azure
• ScienceSoft, etc.
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
Disadvantages
• Response Time: The large size of centralized databases can lead to slower data retrieval
times.
7
Database Management System
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.
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.
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.
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
Disadvantages
• 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.
• 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.
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
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
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.
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.
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.
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.
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
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.
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.
• 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 users query language, helpful to insert, retrieve, update, and delete the
data in a database.
15
Database Management System
7. Define Data Model? What are the various types of data models used?
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.
16
Database Management System
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.
Components of ER Model:
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.
• This type of Data Models are designed and developed for a business audience.
Conceptual data models known as Domain models create a common vocabulary for all
stakeholders by establishing basic concepts and scope
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.
• Relational models like Relational Algebra and Relational Calculus are commonly used.
18
Database Management System
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.
• 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.
• Columns should have exact datatypes, lengths assigned and default values.
• Primary and Foreign keys, views, indexes, access profiles, and authorizations, etc. are
defined
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.
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.
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.
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.
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
2. It helps us in finding the missing data and also in minimizing Data Redundancy.
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.
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.
5. To develop Data model one should know physical data stored characteristics.
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.
• 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.
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
• 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.
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 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.
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:
Each category serves a different purpose within the database management process. Let’s break
down each one.
25
Database Management System
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.
• ALTER: Used to modify the structure of an existing database object, such as adding a
new column to a table.
• TRUNCATE: Used to remove all rows from a table, without affecting the structure.
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
Example:
26
Database Management System
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
Example:
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
Example:
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
Example:
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:
Example:
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.
Now we will explain these commands with proper examples for better understanding
Grant Command
29
Database Management System
Syntax
GRANT privileges
ON object
TO user_or_role [WITH GRANT OPTION];
Example:
Revoke Command
Syntax
Example
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.
30
Database Management System
• 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
Example:
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
31
Database Management System
Example:
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
Example:
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:
Example:
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:
33
Database Management System
Example:
Output
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:
Example:
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:
Example:
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:
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:
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.
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.
2. Forms-Based Interfaces
37
Database Management System
• Description: Displays database schema visually (e.g., diagram form) and lets users
interact with it.
• Usage: Widely used in modern DBMS tools like MySQL Workbench, Oracle SQL
Developer.
• Description: Accept user input in natural language (e.g., English) and interpret it to
generate database queries.
• Process:
• Functionality: Speech recognition for query input and speech synthesis for output.
38
Database Management System
• 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?
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.
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.
40
Database Management System
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
41
Database Management System
Example of DDL
In this example, a new table called employees is created with columns for employee ID, first
name, last name, and hire date.
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
Example of DQL
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.
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.
43
Database Management System
Table control
LOCK LOCK TABLE table_name IN lock_mode;
concurrency
Call a PL/SQL or
CALL CALL procedure_name(arguments);
JAVA subprogram
Example of DML
This query inserts a new record into the employees table with the first name ‘Jane’, last name
‘Smith’, and department ‘HR’.
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.
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.
Example of DCL
This command grants the user user_name the permissions to select and update records in the
employees table.
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
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.
46
Database Management System
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.
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.
• 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.
• 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
• 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 Model is used to model the logical view of the system from a data perspective which
consists of these symbols:
• Lines: Lines represent attributes to entities and entity sets with other relationship types.
49
Database Management System
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.
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:
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
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.
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.
i. University Database:
Relationships: Enroll (between Student and Course), Teaches (between Professor and Course),
BelongsTo (between Student and Department)
51
Database Management System
52
Database Management System
53
Database Management System
54
Database Management 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.
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."
Examples
56
Database Management System
Advertisement
Mute
Fullscreen
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."
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.
Examples
customer_id INT,
first_name VARCHAR(50),
last_name VARCHAR(50)
);
order_id INT,
product_id INT,
quantity INT
);
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
2. Data Integrity
3. Normalization
5. Scalability
6. Security
59
Database Management System
7. Performance
o Optimize for query speed using indexes, denormalization (when needed), and
caching.
8. Relationships
o Carefully map relationships (1:1, 1:M, M:N) using foreign keys or bridge tables.
o Include support for regular data backup and quick recovery mechanisms.
3. Data Integrity
o Enforcing entity, referential, and domain integrity ensures valid data entry.
4. Entity-Relationship Mapping
6. Schema Evolution
o The design must allow for changes over time without breaking existing
functionality.
****************************************
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