Introduction To DBMS Theory and Practicals
Introduction To DBMS Theory and Practicals
Introduction to DBMS:
Theory & Practicals
Author
Dr. Myneni Madhu Bala,
Professor, Department of Computer Science Engineering,
Institute of Aeronautical Engineering,
Medchal, Malkajgiri‐500043, Telangana
Reviewer
Dr. Sanjiva Shankar Dubey,
Professor, Birla Institute of Management Technology,
Greater Noida, Gautam Buddha Nagar‐201306, Uttar Pradesh
ii
BOOK AUTHOR DETAILS
Dr. Myneni Madhu Bala, Professor, Department of Computer Science Engineering, Institute of
Aeronautical Engineering, Medchal, Malkajgiri-500043, Telangana
Email ID: [email protected]
December, 2022
© All India Council for Technical Education (AICTE)
ISBN : 978-81-960386-1-8
All rights reserved. No part of this work may be reproduced in any form, by mimeograph or
any other means, without permission in writing from the All India Council for Technical
Education (AICTE).
Further information about All India Council for Technical Education (AICTE) courses may be
obtained from the Council Office at Nelson Mandela Marg, Vasant Kunj, New Delhi-110070.
Printed and published by All India Council for Technical Education (AICTE), New Delhi.
Laser Typeset by:
Printed at:
Disclaimer: The website links provided by the author in this book are placed for informational,
educational & reference purpose only. The Publisher do not endorse these website links or the
views of the speaker / content of the said weblinks. In case of any dispute, all legal matters to be
settled under Delhi Jurisdiction, only.
iii
iv
ACKNOWLEDGEMENT
The authors are grateful to the authorities of AICTE, particularly Prof. M. Jagadesh Kumar,
Chairman; Prof. M. P. Poonia, Vice-Chairman; Prof. Rajive Kumar, Member-Secretary
and Dr. Amit Kumar Srivastava, Director, Faculty Development Cell for their planning to
publish the books on Introductions to DBMS: Theory & Practicals. We sincerely
acknowledge the valuable contributions of the reviewer of the book Dr. Sanjiva Shankar
Dubey, Professor, Birla Institute of Management Technology for making it students’
friendly and giving a better shape in an artistic manner.
This book is an outcome of various suggestions of AICTE members, experts and authors
who shared their opinion and thought to further develop the engineering education in our
country. Acknowledgements are due to the contributors and different workers in this field
whose published books, review articles, papers, photographs, footnotes, references and
other valuable information enriched us at the time of writing the book.
v
PREFACE
The book titled “Introduction to DBMS: Theory and Practicals” is an outcome of the rich
experience of our teaching of computer science courses. The initiation of writing this book
is to expose database systems to the computer science students, the fundamentals of
dababase systems as well as enable them to get an insight of the subject. Keeping in mind
the purpose of wide coverage as well as to provide essential supplementary information,
we have included the topics recommended by AICTE, in a very systematic and orderly
manner throughout the book. Efforts have been made to explain the fundamental concepts
of the subject in the simplest possible way.
During the process of preparation of the manuscript, we have considered the various
standard text books and accordingly we have developed sections like numerical problems,
case studies with solutions and practical sections etc. While preparing the different sections
emphasis has also been laid on definitions, syntaxes and semantics and also on
comprehensive synopsis of syntaxes and semantics and algorithms for a quick revision of
the core concepts. The book covers all types of medium and advanced level problems/case
studies and these have been presented in a very logical and systematic manner. The stages
of those case studies have been tested over many years of teaching to a wide variety of
students.
Apart from illustrations and examples as required, we have enriched the book with
solved case studies in every unit for proper understanding of the related topics. It is
important to note that in each unit, we have included the relevant laboratory practical. In
addition, besides some essential information for the users under the heading “Know More”
we have clarified some essential basic information in the appendix and annexure section.
As far as the present book is concerned, “Introduction to DBMS: Theory & Practicals”
is meant to provide a thorough grounding in database systems on the topics covered. This
part of the computer science book will prepare diploma students to apply the knowledge
of database systems to tackle 21st century and onward engineering challenges and address
the related stimulated questions. The subject matters are presented in a constructive manner
so that an computer science diploma prepares students to work in different sectors or in
national laboratories at the very forefront of technology.
vi
We sincerely hope that the book will inspire the students to learn and discuss the ideas
behind basic principles of relational database management systems and will surely
contribute to the development of a solid foundation of the subject. We would be thankful
to all beneficial comments and suggestions which will contribute to the improvement of
the future editions of the book. It gives us immense pleasure to place this book in the hands
of the teachers and students. It was indeed a big pleasure to work on different aspects
covering in the book.
vii
OUTCOME BASED EDUCATION
For the implementation of an outcome based education the first requirement is to develop
an outcome based curriculum and incorporate an outcome based assessment in the
education system. By going through outcome based assessments, evaluators will be able to
evaluate whether the students have achieved the outlined standard, specific and measurable
outcomes. With the proper incorporation of outcome based education there will be a
definite commitment to achieve a minimum standard for all learners without giving up at
any level. At the end of the programme running with the aid of outcome based education,
a student will be able to arrive at the following outcomes:
Programme Outcomes (POs) are statements that describe what students are expected
to know and be able to do upon graduating from the program. These relate to the skills,
knowledge, analytical ability attitude and behaviour that students acquire through the
program. The POs essentially indicate what the students can do from subject-wise
knowledge acquired by them during the program. As such, POs define the professional
profile of an engineering diploma graduate.
National Board of Accreditation (NBA) has defined the following seven POs for an
Engineering diploma graduate:
PO1. Basic and Discipline specific knowledge: Apply knowledge of basic mathematics,
science and engineering fundamentals and engineering specialization to solve the
engineering problems.
PO2. Problem analysis: Identify and analyses well-defined engineering problems using
codified standard methods.
PO3. Design/ development of solutions: Design solutions for well-defined technical
problems and assist with the design of systems components or processes to meet
specified needs.
PO4. Engineering Tools, Experimentation and Testing: Apply modern engineering
tools and appropriate technique to conduct standard tests and measurements.
PO5. Engineering practices for society, sustainability and environment: Apply
appropriate technology in context of society, sustainability, environment and ethical
practices.
PO6. Project Management: Use engineering management principles individually, as a
team member or a leader to manage projects and effectively communicate about well-
defined engineering activities.
PO7. Life-long learning: Ability to analyse individual needs and engage in updating in
the context of technological changes.
viii
COURSE OUTCOMES
By the end of the course the students are expected to learn:
CO-1: How to design a database, database-based applications
CO-2: How to use a DBMS.
CO-3: The critical role of database system in designing several information system-based
software systems or applications.
CO-1 3 3 3 3 1 1 3
CO-2 3 2 2 2 1 1 3
CO-3 3 3 3 3 1 1 3
ix
GUIDELINES FOR TEACHERS
To implement Outcome Based Education (OBE) knowledge level and skill set of the
students should be enhanced. Teachers should take a major responsibility for the proper
implementation of OBE. Some of the responsibilities (not limited to) for the teachers in
OBE system may be as follows:
Within reasonable constraint, they should manipulate time to the best advantage of
all students.
They should assess the students only upon certain defined criterion without
considering any other potential ineligibility to discriminate them.
They should try to grow the learning abilities of the students to a certain level before
they leave the institute.
They should try to ensure that all the students are equipped with the quality
knowledge as well as competence after they finish their education.
They should always encourage the students to develop their ultimate performance
capabilities.
They should facilitate and encourage group work and team work to consolidate
newer approach.
They should follow Blooms taxonomy in every part of the assessment.
x
GUIDELINES FOR STUDENTS
Students should take equal responsibility for implementing the OBE. Some of the
responsibilities (not limited to) for the students in OBE system are as follows:
Students should be well aware of each Unit Outcome (UO) before the start of a unit
in each and every course.
Students should be well aware of each Course Outcome (CO) before the start of the
course.
Students should be well aware of each Programme Outcome (PO) before the start
of the programme.
Students should think critically and reasonably with proper reflection and action.
Learning of the students should be connected and integrated with practical and real
life consequences.
Students should be well aware of their competency at every level of OBE.
xi
ABBREVIATIONS AND SYMBOLS
List of Abbreviations
General Terms
Abbreviations Full form Abbreviations Full form
DB Database SQL Structured Query Language
DBMS Database Management OODB Object-Oriented Databases
Systems
DBA Database Administrators XML Extensible Markup
Language
ER Entity-Relationship EER Enhanced Entity-
Relationship
DML Data Manipulation TRC Tuple Relational Calculus
Language
DDL Data Definition Language DRC Domain Relational Calculus
PC Personal Computer TCL Transaction Control
Language
ODBC Open Database Connectivity DCL Data Control Language
JDBC Java Database Connectivity IC Integrity Constraints
WWW World Wide Web FD Functional Dependencies
List of Symbols
Symbols Description
∨ OR
∧ AND
¬ NOT
∃ there exists
∀ for all
AXB Cartesian-Product Operation
⋈ natural-join
σ Sigma selection
Π Pi Projection
− difference
∪ Union
xii
LIST OF FIGURES
Unit 1 Introduction
xiii
Fig. 3.8 : Linear algebra- comparison operators 73
Fig. 3.9 : Relational algebra basic operations 74
Fig. 3.10: A sample Instructor relation instance 74
Fig. 3.11: Relations A and B with sample data, and AXB resultant relation
76
without projection and selection
Fig. 3.12: Cartesian-Product Operation AXB resultant relation with selection
76
and projection
Fig. 3.13: The result of natural-join: Employee ⋈ Department 77
xiv
CONTENTS
Foreword iv
Acknowledgement v
Preface vi
Outcome Based Education viii
Course Outcomes ix
Guidelines for Teachers x
Guidelines for Students xi
Abbreviations and Symbols xii
List of Figures xiii
Unit specifics 1
Rationale 2
Pre-requisites 2
Unit outcomes 2
1.1 Database Fundamentals 3
1.1.1 Need and Importance of Database Systems 4
1.1.2 Data View 5
1.1.3 Example Database System of a College 7
1.1.4 Database Design 10
1.1.5 Database System Evolution 10
1.1.6 Users of Databases 11
1.2 Concepts of a Database 13
1.2.1 A Data Model and Schema 14
1.2.2 Instances, Schema Constructs, State of Database 15
1.3 Architecture 16
1.3.1 Storage and Querying of Data 19
1.3.2 Database Architectures 20
1.3.3 Database Languages 23
1.4 Advantages of Database Systems in Real-Time Applications 25
1.4.1 Database Applications with Network and Hierarchical Systems 25
Unit Summary 27
Exercises 29
xv
Multiple Choice Questions 29
Short And Long Answer Type Questions 31
Numerical Problems 31
Practical 32
Know More 33
Commercial Db Systems 33
Free/Public Domain Database Systems 33
References and Suggested Readings 34
Unit specifics 35
Rationale 36
Pre-requisites 36
Unit outcomes 36
2.1 Conceptual Modeling 37
2.2 An Example Database Application 38
2.3 ER Model Concepts 40
2.3.1 Entity 40
2.3.2 Attribute 41
2.3.3 Keys 43
2.3.4 Relationship Sets 44
2.3.5 Mapping cardinalities 45
2.3.6 Standard notations for ER Diagrams 46
2.3.7 Case study – Library Management System 47
2.4 Enhanced Entity Relationship (EER) Model concepts 49
2.4.1 Subtype or Subclass 50
2.4.2 Specialization, Generalization and Lattices 50
Unit Summary 52
Exercises 54
Multiple Choice Questions 54
Short And Long Answer Type Questions 56
Numerical Problems 58
Practical 59
Know More 60
Commercial Db Systems 60
Free/Public Domain Database Systems 60
References and Suggested Readings 60
xvi
Unit 3: Relational Model and Formal Query Languages 62-87
Unit specifics 62
Rationale 63
Pre-requisites 63
Unit outcomes 63
3.1 Relational Data Model 64
3.1.1. Relational Model Concepts 64
3.2. Relational Database Constraints 67
3.3. ER/EER to Relational Model Mapping 69
3.3.1. Case Study 1: The Conceptual Design of Industry database 69
3.3.2. Case Study 2: The Conceptual Design of the Library Management System
71
(LMS)
3.4. Relational Algebra 73
3.5. Relational Calculus 77
3.5.1. Tuple Relational Calculus (TRC) 78
3.5.2. Domain Relational Calculus (DRC) 78
Unit summary 80
Exercises 82
Multiple Choice Questions 82
Short And Long Answer Type Questions 84
Numerical Problems 84
Practical 86
Commercial Db Systems 87
Free/Public Domain Database Systems 87
References and Suggested Readings 87
Unit specifics 88
Rationale 89
Pre-requisites 89
Unit outcomes 89
4.1 Structured Query Language (SQL-99) 90
4.2 Schema Definition 91
4.3 Constraints 94
4.3.1 Integrity Constraints 94
4.3.2. Domain Constraints 96
xvii
4.3.3. Data Types in SQL 97
4.3.4. Attribute Constraints and Defaults 100
4.3.5. Case Study – College Database 102
4.3.6. Case Study – Library Management System 104
4.4 Queries 105
4.4.1. Basic Structure of Query 105
4.4.2. Additional Basic Operations 107
4.5. Views 112
4.6. Security 114
4.7. Introduction to SQL Programming Techniques 115
4.7.1. Structure of Pl SQL Block 116
4.7.2. PL/SQL – Operators 118
4.7.3. Sequences 118
4.7.4. PL/SQL Control Structures 119
4.7.5. Cursors 121
4.7.6. Transactions 124
4.7.7. Procedures and Functions 125
4.7.8. Exceptions Handling 126
4.7.9. Triggers 128
Unit summary 132
Exercises 137
Multiple Choice Questions 137
Short And Long Answer Type Questions 139
Numerical Problems 140
Practical 141
Commercial Db Systems 142
Free/Public Domain Database Systems 142
References and Suggested Readings 142
xviii
5.3.1 First Normal Form (1NF) 151
5.3.2 Second Normal Form (2NF) 153
5.3.3 Third Normal Form (3NF) 155
5.3.4 Boyes Codd Normal Form (BCNF) 157
5.3.5 Fourth Normal Form (4NF) 158
5.3.6 Fifth Normal Form (5NF) 160
5.4 Relational Database Design Algorithms 161
5.4.1 Closure Algorithm 161
5.4.2 Minimal Cover Algorithm 161
5.4.3 Finding Key of a Relation 162
5.4.4 Testing for Nonadditive Join Property 162
5.4.5 Synthesis on 3NF with Dependency Preservation and Nonadditive Join 163
5.4.6 Decomposition into BCNF with Nonadditive Join Property 164
5.4.7 Decomposition Into 4NF Relations with Nonadditive Join Property 165
5.5 Further Dependencies 166
5.5.1 Inclusion Dependencies 166
5.5.2 Based on Arithmetic Functions and Procedures 167
Unit summary 168
Exercises 169
Multiple Choice Questions 169
Short and Long Answer Type Questions 173
Numerical Problems 175
Practicals 176
Know more 178
References and suggested readings 178
xix
Introduction to DBMS: Theory & Practicals 1
1 INTRODUCTION
UNIT SPECIFICS
RATIONALE
This Introduction unit on Database systems helps students to get a primary idea about the real-
time database applications, needs, and importance of relational database systems. It explains the
concepts, models, schemas, users, languages, and architectures of the database system. All these
basic aspects are relevant to starting the database system implementation. It then explains clearly
about database model, schema development, and architecture views. All these are discussed at
length to develop the database systems. Some related case studies are pointed out with an extension
to the data model and schema development, which can help further in getting a clear idea of the
concern topics on database systems.
Databases are an important branch of computer science that essentially deals with information
and data and their effect on information retrieval. Database systems started their journey by
traditional data processing (file system) and storage and then explaining it in terms of relational
database management. This permits one to analyze the operations of many day-to-day transactions
around us. But at the same time, it covers the database interactions and interfaces of the web, XML,
and cloud. Its practical applications are related to the model, construction, and operation of
different types of database systems and tools.
PRE-REQUISITES
Mathematics: Calculus, Algebra (Class XII)
Computer Science: problem-solving with programming (Class XII)
UNIT OUTCOMES
The List of outcomes of this unit is as follows:
U1-O1: Relate the real-time systems with database systems
U1-O2: Realize the need and importance of database systems for storage, manipulation, and
retrieval of data.
U1-O3: Summarize the architectural views of the database system
U1-O4: Interpret the database system with schemas
U1-O5: Develop a database model with schema and languages for real-time system
EXPECTED MAPPING WITH COURSE OUTCOMES
Unit-1 (1- Weak Correlation; 2- Medium correlation; 3- Strong Correlation)
Outcomes
CO-1 CO-2 CO-3 CO-4 CO-5 CO-6
U1-O1 3 1 3 - - -
U1-O2 1 1 1 - - -
U1-O3 2 2 3 - - -
U1-O4 3 3 3 - - -
U1-O5 3 3 3 - - -
Introduction to DBMS: Theory & Practicals 3
A database (DB) system is a collection of related data, which refers to well-known facts
that may be noted down and have underlying significance.
Examples include the names, numbers, and addresses of the employees and
students.
A computer system and programs like Microsoft Access or Excel are used to process
and store this information on disk or an indexed address book.
Along with the characteristics, it must have a target audience in mind as well as have
user-facing applications.
Introduction to DBMS: Theory & Practicals 4
Accessing data: Once a specific application software is created for a task. Other tasks
cannot be done; they are not supported. For instance, the software is created to
retrieve a list of all students. It does not support collecting a list of students who have
successfully finished 22 credits. Because of this, traditional file processing
environments do not efficiently or easily support all necessary data retrievals.
Storing redundant data: Data redundancy occurs when the same information appears
several times in a typical file processing context. For instance, if a student majors
major mathematics and botany, the address and phone number of such student may
be found in a file that contains student records from both departments. Due to the
redundancy, storage and access costs are increased. Additionally, it can result in
inconsistent data. For instance, the records of another department may not reflect a
change in a contact number made in one department.
Data Isolation: In a typical file processing environment, all relevant data is dispersed
among numerous files in diverse formats. As a result, retrieving right data through
application programs is challenging.
with them. When limitations contain several data items from various files, the issue
is exacerbated.
Concurrent access: A faster response time and allowing numerous users to update the
data at once are key to the system's overall performance. In a file processing context,
it is not feasible.
In real-time, the usability and popularity of a software system rely on the effective retrieval
of data. In all ways, many users are not computer proficient. Therefore, to make users'
interactions with the system simpler, developers hide the complexity from users at
several levels of abstraction.
All the data is not required by all database users. Users must therefore only access a portion
of the database. To make their engagement with the system simpler, there is a view
level of abstraction. For the same database, the system might offer a variety of views.
The link between the three levels of abstraction is depicted in Fig. 1.1. (Low to high).
Physical Level - How the data is
physically stored.
Logical Level - What data and
relationships among them are stored in
the database? This is referred to as
physical data independence. The
Database administrators (DBA) will Fig. 1.1 Levels of Data View
Introduction to DBMS: Theory & Practicals 6
Physical Level:
Faculty, department, course, and student records can be thought of as a block of successive
storage spaces on a physical level. Database administrators are concerned with the
particulars of data stored physically.
Logical Level:
Each record's type description and how these record types relate to one another are
explained at the logical level. At this level of abstraction, programming languages
are used by database managers and programmers.
Finally, system users perceive a collection of applications at the view level that hides the
specifics of the data kinds. A database user can view exactly required or everything
available (different views) that have been defined for the database. The different
levels of views provide security by restricting users from specific areas of the
database access by hiding the logical level of the information.
In the college office, for instance, assistants can view students (a portion of the
database), but they are restricted to access information regarding the salaries of faculty.
Introduction to DBMS: Theory & Practicals 7
In order to define this database, we must describe the data items that will be kept in
each record's structure shown in figure 1.2.
STUDENT data contains information about the Roll_ number, student_ Name, Class
(like Firstyear / "1", Secondyear / "2" ), Major course(“Mathematics” / "MATH" and
“Computer Science” / "CS").
COURSE data contains information about the course_ name, number of credits, offered
department.
For every data element contained within a record, a data type must also be specified.
GRADE REPORT data contains a Grade (a single character in the given set {"A," "B,"
"C," "D," "F," and "I,"} and name of student is a string (having alphabetic characters),
Roll number is an integer.
The values of a data item may alternatively be represented via a coding scheme.
The Class of a STUDENT (such as 1, 2, 3, 4, and 5 for freshmen, sophomore, junior,
senior, and graduate student, respectively.
We keep information in the relevant file to denote as student details, course details,
section, grade details, and pre requisites as a record in order to build the college
database. It should be noted that records in different files might be connected.
For instance, (in figure 1.2), in the GRADE REPORT file two records details are filled
with amit grades in one section are tied to the record for amit in the STUDENT file.
In the PREREQUISITE file, each entry is linked with two course records, one for the
course itself and the other for the prerequisite.
Introduction to DBMS: Theory & Practicals 9
Querying and updating are two aspects of database manipulation. The following are
some examples of queries:
Get “Amit’s” transcript, which contains a list of all of his or her courses and
grades.
List the prerequisites for the "Database" course;
Display the student names, who acquired the section of the course given in even
2020 and their grades;
Provide examples of changes, such as the following:
Create a new segment of the "Database" with a courses for this semester.
Change "Amit" class to sophomores. Enter "Amit" grade of "A" in the
"Database" section from previous sem.
There are three stages to the database design process Conceptual, Logical, and Physical.
The requirement specification and analysis phase is the first step in designing a new
application for both an existing database and a brand-new database. To make it
simple to maintain, modify, and convert into a database implementation, these
specifications are recorded and turned into a conceptual design that can be
represented and edited using computerized tools. A Logical design of a system to be
represented is done through a commercial DBMS.
decentralized contexts and files on tapes and discs. Over time, data processing has
progressed beyond payroll management to data analysis. Fig. 1.3 depicts the
development of database systems from 1960 to 2000.
Administrators of databases
The Database Administrator (DBA) is the authority of granting users access to the
database, organizing and controlling how it is used, and organizing necessary
hardware and software resources. Security lapses and slow system responses are a
few of the issues handled by the DBA.
Introduction to DBMS: Theory & Practicals 12
Designers of Database
The database designers are responsible to determine the data that will be stored in the
database and selecting the best structures for representing and store. Utmost all these
actions are carried out prior to the database's implementation and data loading.
All potential database users must be contacted for database designers to fully comprehend
their needs and develop a satisfactory design. They gain insights by interacting with
each possible user group and then create views of the database that provide for their
processing needs. The ultimate database design must be able to accommodate all user
groups' needs.
End Users:
The people involved in querying, updating, and producing reports from databases are
known as end users. There are various types of end users, including:
Casual end users - who infrequently and for various purposes - access the database. To
describe their requests, they use a simple database query language. They are
supervisors at medium or high levels or other infrequent browsers.
Naïve/parametric Users - Their primary duty is to continuously update and query the
database using pre-programmed, thoroughly tested transactions, which are common.
These users carry out a variety of tasks:
1. Account balances are checked by bank tellers, who also post deposits and withdrawals.
2. Airlines, hotels, and car rental agencies all have reservation agents who can check
availability and book bookings.
To update a database with all received parcels, workers at receiving stations for shipping
businesses.
3. Engineers, scientists, business analysts, and other professionals with in-depth knowledge
of the DBMS's features are examples of sophisticated end users.
Introduction to DBMS: Theory & Practicals 13
Independent users - manage their databases by utilizing pre-built software packages that
offer simple menus or graphics-based user interfaces.
They will identify the needs of users, particularly simple and parametric users to create
specifications for pre-packaged standard transactions that fullfil these requirements.
Application programmers convert these specifications into working programs, which
they subsequently test, debug, record, and maintain. To effectively carry out their
duties, these analysts and programmers—often referred to as software developers or
software engineers—should be knowledgeable about the full scope of DBMS
capabilities.
Designers and implementers of DBMS systems
They are concerned with creating a software package that includes the DBMS modules and
interfaces. It is composed of several parts, or modules, such as those that implement
the catalog, process query languages, process user interfaces, access, and buffer data,
manage concurrency, handle data recovery, and handle security.
Tool Developers:
The tool developers will create packages to simplify database modelling and design, and
for enhancing performance.
Operators and maintenance personnel:
The responsibility of operators and maintenance employees (system administration
personnel) is the effective functioning of the database system and maintenance of the
environment including hardware and software.
A data model is a collection of interrelated concepts that are used to define the database
structure. It includes the related data type, relationship, and required constraints. It
provides data abstraction to access different levels of users at their chosen level.
The data models have been categorized according to the types of concepts used:
3. Representational / implementation
All high-level concepts (users recognized data) are named as an ‘entity’, ‘attribute’, and
‘relationship’.
The low-level representation of data on physical storage (Eg. Magnetic disks) includes the
files related to record format, ordering, and access details.
Introduction to DBMS: Theory & Practicals 15
3. Implementation / Representational
The concepts are represented in an easily understandable way and hide storage details of
the disk for end users. It is a commonly used model in commercial database
management systems. The representational DB models are relational, legacy models
like hierarchical and network.
Schema:
Instances:
Introduction to DBMS: Theory & Practicals 16
The instances are present sets of incidents in the database, also termed the state of a
database or snapshot.
Shema Construct:
In any given state of the database, each schema construct is represented as a set of related
instances.
State of Database:
A database update with an insert, delete or change in data value in a record alters the state
of a database. It does not affect the database schema. In general, several database
states are raised to a specific database schema. The database states are listed as Initial,
Empty, Current, and Valid. Fig. 1.5 illustrates the various database states and
descriptions.
1.3. ARCHITECTURE
The database architecture captures the many essential functional modules of a DB system
along with the associations existed between them. The database architecture
comprises essential components as illustrated in Fig. 1.6. It is significantly inclined
Introduction to DBMS: Theory & Practicals 17
by the computer system with the database system. The database system comprises of
majorly two functional components:
1. Storage Manager
2. Query Processor
Each component is again accommodated with multiple database tables. And multiple types
of users are connected through respective interfaces to the database system.
Introduction to DBMS: Theory & Practicals 18
based on the requirement. This movement leads to slow processing. Hence, a system
must minimize the need to move data between disk and main memory.
2. Data Dictionary – maintains the metadata (i.e. the structure of the database).
3. Indices – all index terms are stored; it is used to fast access data items.
Eg. Find the faculty data- with a specific faculty_ID, or all faculty_IDs.
The above tasks are completed by using an index of ID. Hashing technique is an alternative
to indexing; It is faster in few cases but not in all cases.
4. Statistical Data – All statistical parameters of the data, used by the query processor to
execute the query efficiently.
Storage Manager:
The storage manager acts as an interface in the middle of the disk storage (for low-level
data) and the application programs or queries submitted to the system. It holds the
accountability of interaction with the file manager; stores the raw data on the disk in
the file system of operating systems; translates the DML statements into file system
instructions. Therefore, the storage manager is accountable for the storage, retrieval,
and updates of data in the database.
Introduction to DBMS: Theory & Practicals 20
1. Authorization and integrity manager ensures the constraints of data integrity and the
access details of the authorized users.
2. Transaction manager ensures the database maintains in a consistent (correct) state in the
aspect of system failures, and concurrent transactions without raising conflicts.
3. File manager is accountable for the distribution of disk space and appropriate data
structure used to store on disk.
4. Buffer manager is accountable for fetching data from disk into main memory, and
allocation to cache memory.
Query Processor:
The query processor translates the Data Manipulation Language(DML) and Data
Definition Language(DDL) commands into a set of activities at the physical level of
the database. The components include:
1. DDL interpreter – It interprets DDL commands and results from records are stored in
the data dictionary.
2. DML compiler – It translates DML commands into low-level instructions which are
understood by query evaluation engine.
Usually, a query is translated into no. of substitute evaluation procedures. It performs query
optimization (i.e, the cost-effective evaluation among the changes).
4. DDL Interpreter – interprets the DDL Statements and recorded them as metadata.
The centralized architecture contains all hardware and software components (Application
programs, user interface programs, database software, and compilers) which are
available in one system (mainframe system) to process all functionalities of the
database, applications programs, and user interface functionalities. Fig. 1.7 illustrates
the components in a centralized architecture.
In this system, a client is a user machine that offers local processing and user interface
capabilities. When a client requests more capability, such as database access, a server
is connected via a communication network. A server is a computer system that
combines hardware and software that can offer client computers services like file
access, printing, archiving, or database access.
Applications for databases are usually divided into two or three components.
In a 2-tier paradigm, the application is located on the
client-side machine and uses query language
statements to access database system
capabilities on the server machine. For
establishing communication between the client
and server machines, application program
interface standards like ODBC and JDBC are
Fig. 1.9. A 2-tier Architecture
engaged. The structure of the 2-tier database is
shown in Fig. 1.9.
Introduction to DBMS: Theory & Practicals 23
Data definition language (DDL) is used to state the database schema and a data
manipulation language (DML) is used to execute database queries and updates. In
practice, the DDL and DML are not two separate languages; parts of a Structured
Query Language (SQL). SQL is covered in detail in chapter 4.
A DDL is used by DBA and database designers to define schemas and constraints to
maintain consistency in the database. These are required only after one has done the
initial phase of finalizing the data design and implementation of the database in the
language of their choice.
Consider the scenario, where the college mandates that a department's account
balance never go negative.
Introduction to DBMS: Theory & Practicals 24
The DDL offers tools for defining such limitations. For every update, the DB system
checks these limitations. Various limitations are discussed further.
Domain Constraint: A domain value is linked with all attributes (Eg., integer, character,
date/time). These are the utmost basic form of integrity constraints. These are verified
by the DB system on the entry of a new record.
For instance, each course's department name must be an existing object. More
specifically, the deptname in the department table must match the deptname in the
course record.
Assertions: The conditions that the database must satisfy all the time. The constraints such
as Domain, and referential integrity are considered as special forms of assertions.
Eg., “Every department must have at least five courses offered in every semester”
- articulated as an assertion.
Authorization: To implement data
abstraction, the users are differentiated
Authorizations:
based on the diverse types of access they Read - permits to read not
are permitted. These differentiations are modification of data
Insert - allows insertions of
expressed in terms of authorizations to the new records, but not
most common users such as read, insert, modification of existing
data
update and delete. The user access may
Update - allows
assign all, none, or a combination of these modifications but not
deletion of data
types of authorization.
Introduction to DBMS: Theory & Practicals 25
Users need to have a method for modifying the database once the database schemas are
put together and filled with data. Data retrieval, insertion, deletion, and
modification are typical manipulations. For these uses, the DBMS offers a
collection of operations or a language known as the data manipulation language
(DML).
The data dictionary contains the metadata i.e, data about data - contains the result of
the DDL. It is believed that the data dictionary is a unique kind of table that can
only be read and modified by the database system itself (not a regular user). The
data dictionary is consulted by the database system before reading or editing
actual data.
3. Object-oriented databases
4. XML databases
The combination of abstract relationships along with the physical storage and storing
records on the disc was one of the key issues with early database systems. As a result,
these systems lacked adequate capabilities for program-data independence and data
abstraction. Early systems had the drawback of just offering programming language
Introduction to DBMS: Theory & Practicals 26
interfaces. Because new programs had to be built, tested, and debugged, adding
additional queries and transactions became time-consuming and expensive.
Relational databases' ability to abstract data and increase application flexibility
With the motto of separation between the actual storage from its conceptual illustration
and to establish a mathematical foundation for data representation and querying,
relational databases were first proposed. High-level query languages with
programming language interfaces were also made available by the relational data
architecture allowing significantly faster creation of new queries.
As with past systems, initially, relational database systems were designed for the same
applications and offered the flexibility to create new queries rapidly and rearrange
the database as needs evolved. In comparison to preceding systems, data abstraction
and program-data independence were therefore greatly enhanced. New indexing and
stored methods helped boost performance and enhance query processing and
optimization.
The development of OOP languages (the1980s) with the essentiality for storing and sharing
complex and structured objects directed the growth of OODBs (object-oriented
databases).
Due to the raise in E-Commerce application uses, web documents with HTML are
massively created and required to store on web servers for other clients’ access
through hyperlinks. The XML is used for interchanging data among various DBs and
web pages.
Introduction to DBMS: Theory & Practicals 27
UNIT SUMMARY
EXERCISES
Multiple Choice Questions
1 DML stands for
a. Data Manipulation language
b. Dependency maintenance link
c. Data Mining language
d. Data maintenance language
2 In database management systems (DBMS) usage, the part to understand is
a. Row
b. Record
c. Database
d. File
3 Categories of models in DBMS are
a. Object-based and Record-based
b. Object-based and Field-based
c. Object-based and Bit-based
d. Object-based and Table-based
4 The collection of fields is called
a. Fields
b. Records
c. Database
d. File Based
5 Which one is not a component of a relational database?
a. Entity
b. Attribute
c. Table
d. Hierarchy
6 To use DBMS, the important one to understand is
a. The physical schema
b. All substances that the system supports
c. One sub schema
d. Both (A) and (B)
7 The group of data items for storage is termed as
a. Record
b. Title
c. List
d. String
8 User authorization is the responsibility of the
a. Database administrator
b. Database Manager
c. Database user
d. Database owner
9 To retrieve data from DBMS is referred to as the
Introduction to DBMS: Theory & Practicals 30
a. DML
b. DDL
c. SQL
d. Database language
10 Updating a database means
a. Revising the file structure
b. Modifying or adding a record
c. Reorganizing the database
d. Modifying the database
11 Identify not a valid relational database
a. IMS
b. ORACLE
c. Sybase
d. UNIFY
12 Data about data is called
a. Directory
b. Record
c. Metadata
d. Data Bank
13 Data dictionary stores the details of
a. The data types of all fields of all files
b. The names of all fields in all files
c. Both of the above
d. None of above
14 Data is a collection of
a. raw facts and Fig.s
b. The Electronic representation of facts
c. Information
d. None
15 The founder of the relational database
a. EF Codd
b. kahate
c. James Gossling
d. Dennies Rithchie
16 DBMS are not intended to
a. Eliminate data redundancy
b. Manage files access
c. Maintain data integrity
d. Separate files
17 Indicate an early development of relational model developed by E.F. Codd of IBM?
a. R:base
b. DB2
c. DBase-II
d. IDMS
Introduction to DBMS: Theory & Practicals 31
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
A C A B D C A A C B D C A A A D B C
2. Illustrate major database components with the schema diagram for your college would
maintain.
3. Imagine creating a video portal that is similar to YouTube. Think of the data in a system
for processing files. Describe how each of these elements relates to the storage of
actual video data as well as to the information that describes the video, such as the
title, the user who uploaded it, tags, and the users who watched it.
6. Summarize the database architectures viz. two-tier and three-tier. Suggest a suited
architecture for Web applications.
7. Identify three possible entities that could be utilized to store data in a social networking
system like Facebook.
8. Outline the different types of database end users and their main activities for each
Numerical Problems
1. Refer to Fig. 1.2. If the department name changed to ‘CSSE’ from ‘CS’ and the
corresponding course_number also needs to change. Identify the same columns in the
database that need to be updated according to changes.
Introduction to DBMS: Theory & Practicals 32
2. According to the above change, illustrate the schema diagram of restructured columns
in the COURSE, SECTION, and PREREQUISITE relations so that only one column
will need to be updated.
PRACTICAL
Analysis of Requirements
S Chand Publishing's proprietor offers a statement of his desires about: "My
consumers to be able to explore my collection of books and place orders through
Internet sources. I now only accept phone orders. Most of my callers are business
clients who tells about the ISBN number and the quantity of books. I then put
together a delivery it includes the books ordered. I want to ship the customer's
complete order, so if enough copies are not available on hand, and gets more
number of orders then it leads to delay the shipment until the fresh copies come.
I list all of my books in my catalogue. The catalogue includes the book details as
title of the book, ISBN number, author name, purchase and sales price, and
publication year. The majority of the clients are repeated customers, and have
available records containing names, addresses, and credit_card information.
Prior to using my website, brand-new clients must call me and create an account.
Customers should first identify themselves on my new website using their specific
customer identification number. Then, they ought to have access to my catalogue
and be able to make purchases online.
The requirements phase was accomplished so rapidly that DBGig consultants takes
weeks of discussions to get this done to analyze this information.
Introduction to DBMS: Theory & Practicals 33
KNOW MORE
Edgar F. Codd, the creator of relational databases defined 13 properties of
databases system that should possess in the year 1970 and developed further in a
1974 conference paper.
https://www.red-gate.com/simple-talk/databases/theory-and-design/codds-twelve-
rules/
Commercial DB systems:
MySQL - www.mysql.com
PostgreSQL - www.postgresql.org
Introduction to DBMS: Theory & Practicals 34
2
d
DATA MODELING
UNIT SPECIFICS
Conceptual Modeling
Example Database Application
ER Model Concepts
Data Modeling using the Entity-Relationship Model
The Enhanced Entity-Relationship (EER) model
The practical applications of the topics are discussed for generating further curiosity and creativity
as well as to improve problem-solving capacity.
Besides giving a large number of multiple choice questions as well as questions of short and
long answer types marked in two categories following lower and higher order of Bloom’s
taxonomy, assignments through several numerical problems, a list of references, and suggested
readings are given in the unit so that one can go through them for practice. It is important to note
that for getting more information on various topics of interest some QR codes have been provided
in different sections which can be scanned for relevant supportive knowledge.
After the related practical, based on the content, there is a “Know More” section. This section
has been carefully designed so that the supplementary information provided in this part becomes
beneficial for the users of the book. This section mainly highlights the initial activity, examples of
some interesting facts, analogy, history of the development of the subject focusing on the salient
observations and finding, timelines starting from the development of the concerned topics up to the
recent time, applications of the subject matter for our day-to-day real life or/and industrial
applications on a variety of aspects, case study related to environmental, sustainability, social and
ethical issues whichever applicable, and finally inquisitiveness and curiosity topics of the unit.
Introduction to DBMS: Theory & Practicals 36
RATIONALE
This Data Modeling unit in Database systems helps students to get a primary idea about the real-
time database applications, entity-relationship(ER) model, and extended entity-relationship model.
It explains the need for data modeling, concepts, ER model of a sample application, relationships,
and extended ER modelof the database system. All theseaspects are crucial for designing a
database system implementation. It then explains clearly elements of ER model, a real time
database model. All these are discussed at length to model the database systems. Some related case
studies are pointed out with an extension to the data model, which can help further in getting a
clear idea of the concern topics on database systems.
Databases are an important branch of computer science that essentially deals with information
and data and their effect on information retrieval. Database system implementation needs as a
prerequisite step data modeling and it is termed relational database management. This permits one
to analyze the operations of many day-to-day transactions around us. Its practical applications are
related to the model, construction, and operation of different types of database systems and tools.
PRE-REQUISITES
Mathematics: Calculus, Algebra (Class XII)
Computer Science: problem-solving with programming (Class XII)
UNIT OUTCOMES
The List of outcomes of this unit is as follows:
U2-O1: Summarize the elements of E-R diagrams to visualize the system at conceptual level.
U2-O2: Make use of Entity Relationship (ER) diagrams to design a database system.
U2-O3: Illustrate conceptual design using an ER diagram to represent a real-time database
application.
U2-O4: Outline the enhanced entity-relationship (EER) diagramfeatures to implement the object-
oriented features
U2-O5: Develop a database model with the help of ER/EER diagrams of real-time system
U2-O5 3 3 3 - - -
Step 1: Requirement collection and analysis – database designers interview the prospective
users and document the data requirements.
Step 2: Conceptual schema –a concise description of the data requirements of the users and
details of entity types, relationships, and major constraints. The high-level user
Introduction to DBMS: Theory & Practicals 38
actions and queries observed during functional analysis can be specified either during
or after the conceptual schema design via the fundamental data model operations.
Step 4: Physical design – It specifies the physical design parameters for the database files,
internal storage structures, file organizations, indexes, and access paths.
The ER diagram of the sample industry data model is illustrated in Fig. 2.1. This illustration
will be discussed as ER concepts in detail in further sections.
The major noting’s of the diagram are listed as:
Major Entities: Employee, Division, Project, Dependent
Relationships: Work_for, Manages, Controls, Work_on, Supervision, Relationship
Entity – Attributes:
Entity Attribute 1 Attribute 2 Attribute 3
Employee Emp_No Name Address
Division DIV_No DIV_Name Office_Loc
Project Proj_No P_Name Location
Dependent Name Gender DOB
Introduction to DBMS: Theory & Practicals 40
2.3.1. ENTITY
The basic object that an ER model represents is an entity. It is a thing in the real world with
an independent existence. An entity’s existence is either a physical level (for example
person, car, employee, etc.) or a conceptual level (industry, course, college, job role,
etc.).
Example: Entity set faculty, is the set of all people, who are faculty at a given college.
The entity set student represents the set of all students in the university.
Weak Entity:
A weak entity can be identified uniquely only by considering the primary key of another
(owner) entity. It does not have a single key attribute and it participate in a one-to-
many relationship set (one owner, many weak entities). Weak entity set must have
total participation in this identifying relationship set.
2.3.2. ATTRIBUTE
Each entity has a set of attributes that describe the properties of objects. For example, an
employee entity can describe with name, ID, age, department, location, contact no,
address, salary, and designation. The attribute values of the entity become a major
part of the database.
Fig. 2.3 illustrates the two entities (employee EMP1; Industry IND1). Employee entity has
a set of attributes EMP1(ID, NAME, ADDRESS, SALARY, DIVISION,
CONTACT, AGE) with values (101, Singh, 201, lalbar, highroad), and industry
IND1(Name, Head Quarters, CEO NAME) with Values(Reliance Industries,
Mumbai, Ambani).
Types of Attributes:
The attributes of an entity are categorized based on values stored on it. They are
7. NULL Value - The null value indicates not applicable, missing, or not known
Fig. 2.4 illustrates different types of attributes along with appropriate examples.
2.3.3. KEYS
A constraint on the entities of an entity type is the key or uniqueness constraint on
attributes. An entity has one or more attributes whose values are distinct in the entity
set. Such an attribute is called a key attribute, and its values can be used to identify
each entity uniquely.
Introduction to DBMS: Theory & Practicals 44
Value Sets (or Domains): Value Sets (Domains) of attributes of an entity type are
associated with a value set (or domain of values), which specifies the set of values
that may be assigned to that attribute for each individual entity.
The mathematical representation of an entity set E of an attribute A whose value set is V
can be defined as a function from E to the power set P(V) of V:
A : E → P(V)
The value set provides all possible values of an attribute.
For single-valued or multi-valued and NULL valued attribute is represented as power set
P(V).
single-valued attribute: A(e) is a single value set of the respective entity. Multy-valued
attribute: A(e) is a power set of entity e.
Example: The value set of Attribute Age of student is between 16 and 35 at entry-
level graduation
2.3.4. RELATIONSHIP SETS
A relationship is an association among several entities.
Example: A relationship of mentor: that associates faculty Roy with student srini.
The mathematical relation exists on two or more non-distinct entity sets, n≥2. If E1, E2, E3
are entity sets, then a relationship set R is a subset of
𝑒 , 𝑒 , 𝑒 … . 𝑒 |𝑒 ∈ 𝐸 , 𝑒 ∈ 𝐸 … . . 𝑒 ∈ 𝐸
Constraints: The E-R schema defines the set of constraints to which the database contents
must follow. This is represented in mapping cardinalities and constraints.
2.3.5. MAPPING CARDINALITIES
Mapping cardinalities will direct the total number of entities that a relationship set can be
used to link one entity to another. Although they can help with the description of
relationship sets that include more than two entity sets, mapping cardinalities are
most helpful when expressing binary relationship sets. The mapping cardinality of
binary relationship set R between entity sets A and B are given in Fig. 2.6.
The conceptual design of the library management system (LMS) in Entity- Relationship
model with E-R diagram is presented in the following steps:
Step 1: Recognize the strong entity set and week entity set
Step 2: Identify the related attributes to each entity
Step 3: Identify the relationship sets
Step 4: Detect the mapping cardinalities and participation of entities
Introduction to DBMS: Theory & Practicals 48
Step 1: Strong and Week Step 2: Related attributes of each identified entity
entity sets Book: Book_Id, auther_no, ISBN_no, Title of the book,
Entity - 1: Book edition_no, category_type, price.
Entity - 2: Member ISBN_no is the Key attribute.
Entity - 3: Publisher
Entity - 4: Authentication Member: Member_Id, Mail_Id, address, Contact_no,
Entity - 5: Staff Mem_name.
Mem_Name is a composite attribute of first_name and
last_name.
Contact_no is multi-valued attribute.
member_Id is the Key attribute for the member entity.
Fig. 2.8. Illustration of Conceptual design of the library management system using E-R
diagram
2.4. ENHANCED ENTITY RELATIONSHIP (EER) MODEL CONCEPTS
The Enhanced E-R model includes all E-R model concepts and the concepts of subclass
and super class and the related concepts of specialization and generalization. Another
concept included in the EER model is that of a category or union type, which is used
to represent a collection of objects (entities) that is the union of objects of different
entity types. Associated with these concepts is the important mechanism of attribute
and relationship inheritance.
Introduction to DBMS: Theory & Practicals 50
UNIT SUMMARY
EXERCISES
Multiple Choice Questions
1 ……………..indicates the max. no. of entities existed in a relationship?
A. Greater Entity Count
B. Maximum cardinality
C. Entity Relationship Diagram
D. Minimum cardinality
2 ………….is an association among entities in an E-R model.
A. Record
B. Relationship
C. Field
D. Tuple
3 ……….. entity is a part of a one-to-many relationship.
A. Instance
B. Child
C. Parent
D. Subtype
4 ………entity is associated with the generalization of EER.
A. Archetype
B. Supertype
C. Subtype
D. Instance
5 A specialization relation of EERD may also known as………………...
A. Super-Sub
B. Sub-Super
C. Lower relation
D. Higher relation
6 ………….. indicates the min. no. of entities involved in a relationship.
A. Entity Relationship Diagram
B. Maximum_cardinality
C. Minimum_cardinality
D. Greater Entity Count
7 Mapping cardinality of relations in E-R diagram are describing about
A. composite
B. unary
C. simple
D. binary
8 In ERD illustrations, specialization is represented with
A. solid arrow
B. double arrow
Introduction to DBMS: Theory & Practicals 55
C. hallow arrow
D. dashed arrow
9 ………….relationship is existed between the week entity and the identified entity set.
A. dependency
B. existence
C. Identifying
D. dependency
10 ……………. is used to represent a strong entity in E-R diagram
A. rectangle
B. rhombus
C. oval
D. double-bordered rectangle
11 ……………..is used to represent a multivalued attribute in E-R diagram
A. oval
B. double lined rhombus
C. double lined oval
D. double-bordered rectangle
12 An employee works in the sales department. In this, works relationship exists with a
cardinality of
A. 1-1
B. 1-N
C. N-1
D. M-N
13 The mentor mentors the students in a college. In this, mentors relationship exists with a
cardinality of
A. 1-1
B. 1-N
C. N-1
D. M-N
14 A customer has a loan account. In this, has a relationship exists with
A. 1-1
B. 1-N
C. N-1
D. M-N
15 Contact information is ……………….type of attribute
Introduction to DBMS: Theory & Practicals 56
A. single
B. multi
C. NULL
D. derived
16 BMI value is ……………….type of attribute
A. single
B. multi
C. NULL
D. derived
17 Speed is ……………….type of attribute
A. single
B. multi
C. NULL
D. derived
18 In a student entity set, the undergraduate students are represented with…… relationship
A. IS-AN
B. generalization
C. entity set
D. specialization
Answers to MCQs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
B B A B A C A B C D C A B B B D D D
2. Illustrate the major E-R components used to represent the conceptual view of the
database system.
3. Imagine creating a video portal that is similar to YouTube. Think of the data in a system
for processing files. Describe how each of these elements relates to the storage of
actual video data as well as to the information that describes the video, such as the
title, the user who uploaded it, tags, and the users who watched it.
4. Construct an ER-Diagram for a hospital management system with a set of patients and
medical doctors. A patient log contains a history of tests conducted and consultations
made.
Introduction to DBMS: Theory & Practicals 57
5. Construct an E-R diagram for maintaining a track of the sports team based on interest.
Then a system should store the matches played, the scores in each match, the players
in each match and individual player statistics for each match. Summary statistics
should be modeled as derived attributes.
7. Identify three possible entities and related attributes that could be utilized to maintain
the attributes of a social networking system like LinkedIn.
8. Outline the different types of data modeling techniques and their phases to develop a
database system.
9. Summarize the Enhanced Entity Relationship model concepts with cars example.
Introduction to DBMS: Theory & Practicals 58
Numerical Problems
1.It has been determined by Amazon.com to rearrange its database. Books, sales, and user
data are all stored. Amazon collects as much data as it can on user behaviour so that
it can analyse it and make site improvements. Here are a few prerequisites:
(a) Each user is assigned a special ID, name, password, and email address. Amazon
emails consumers on a regular basis, thus it's crucial to know if the user is okay with
being spammed and if their email address has been returning messages.
(b) Amazon keeps track of a user's most recent visit date so that it can show the user
a list of products that have been added to the site since his previous visit.
(c) Books are identified by their ISDN number, title, author, publisher, and 2.
According to the above change, illustrate the schema diagram of restructured
columns in the COURSE, SECTION, and PREREQUISITE relationsso that only one
column will need to be updated.
To model the above-mentioned data, create an E-R diagram. Recall to include constraints,
important attributes, etc. Mention all presumptions, all required logical assumptions.
Introduction to DBMS: Theory & Practicals 59
PRACTICAL
1. A bank wants to automate each transaction. It provides the subsequent account
types: Fixed Deposit(FD), Recurring Deposit(RD), and Savings Bank (SB)
The Bank also wants to monitor the loans granted to its clients. Determine the entities,
their properties, and any relationships among them.
Draw the ER diagram using any open source tool and make sure to provide all explicit
assumptions. Consider the following presumptions:
a. A customer is limited to having a single type of account. Joint accounts are not
permitted
b. Only when a consumer has at least one of the account kinds is a loan available.
KNOW MORE
Drawing Entity Relationship (E‐R) diagram of Banking Management
system
https://www.youtube.com/watch?v=RVyCJXn--
jY&ab_channel=TechnonTechTV
.
https://www.youtube.com/watch?v=lAtCySGDD48&ab_channel=Dr.D
anielSoper
Introduction to DBMS: Theory & Practicals 62
3
RELATIONAL MODEL AND
d
FORMAL QUERY
UNIT SPECIFICS
RATIONALE
This Relational modeling unit on Database systems helps students to get a basic idea of mapping
of conceptual design to logical design on the real-time database applications and mathematical
tools to perform query processing. It explains the logical design of the system using relational
modelling and formal query languages like relational algebra and calculus are declarative query
languages built on mathematical logic. All these basic mathematical functions are related tobuild
query strings in commercial databases using SQL. All these are discussed at length to develop the
database systems. Some related case studies are pointed out with an extension to the data model
and schema development, which can help further in getting a clear idea of the concern topics on
database systems.
Databases are an important branch of computer science that essentially deals with information
and data and their effect on information retrieval. Structured query language (SQL) statements are
started their journey by mathematical functions using calculus and algebra and then explaining it
in terms of relational database management. This permits one to analyze the operations of many
day-to-day transactions around us. Its practical applications are related to the relationalmodel
construction and operation of different types of database systems and tools.
PRE-REQUISITES
Mathematics: Calculus, Algebra (Class XII)
Computer Science: problem-solving with programming (Class XII)
UNIT OUTCOMES
The List of outcomes of this unit is as follows:
U3-O1: Summarize the Relational modeling components to represent the system at a logical level.
U3-O2: Realize the need and importance of relational data model for implementation with
commercial database systems.
U3-O3: Illustrate logical design using relational representations of a real-time database
application
U3-O4: Interpret the database system with schemas in relational algebra and calculus
EXPECTED MAPPING WITH COURSE OUTCOMES
Unit-3 (1-WeakCorrelation;2-Mediumcorrelation;3-StrongCorrelation)
Outcomes
CO-1 CO-2 CO-3 CO-4 CO-5 CO-6
U3-O1 3 1 3 - - -
U3-O2 1 1 1 - - -
U3-O3 2 2 3 - - -
Introduction to DBMS: Theory & Practicals 64
U3-O4 3 3 3 - - -
The logical and view models are described with relational model. It provides the
conceptualizing of low-level details of data storage. The higher-level data model
discussed later in Chapter 2, entity-relationship(E-R)model is widely used for
database design. The relational data model is a basic model for commercial data
processing applications.
Domain: A set of atomic values is termed a Domain. It is useful to interpret the value
by a specific name in the domain. Each domain is specified with name, data type
and design.
Introduction to DBMS: Theory & Practicals 65
Examples of Domains:
PIN Number – a six digit number refers to “Postal Index Number (PIN)”, or PIN
code to the Indian postal code system used by India.
A Relation schema is indicated as R (A1, A2, ……An) and the degree of relation as a
no. of attributes n of relation and is a set of m-tuples r = {t1, t2, ..., tm}. And a
tuple t is t is a list of m values t =<v1, v2, ..., vm>.
In relation student, first attribute is Student_name, the Second attribute is RollNo, etc
Introduction to DBMS: Theory & Practicals 66
Fig. 3.2 illustrates a sample table of student details. It exists 8 attributes(columns) and
5 tuples (rows) of unique student details.
Database Instance –Itis a snapshot of the data at a given instant in timein the database.
The restrictions or constraints on the database are derived from the rules of the specific
organization. The constraints are categorized into three main categories.
1. Implicit constraints
2. Explicit constraints
3. Semantic constraints
Semantic Constraints–these are not expressed at the schema level and are enforced
by the application-specific programs.
The schema-based constraints include domain, key constraints, null, and integrity
constraints (entity and referential).
Introduction to DBMS: Theory & Practicals 68
Fig. 3.4 lists the constraints in relational databases. These are implemented through
Data Definition Language (DDL) and data types. The constraints on relational
databases are implemented in four ways:
1. Domain level
2. Key level
3. Entity Integrity level
4. Referential integrity level
Super key- a set of one or more attributes whose values are guaranteed to identify tuples
in the relation uniquely.
Entity Relationship (E-R) model and Enhanced Entity Relationship (EER) model at
conceptual design is mapped with the relational model at the logical level in three
steps:
Step 3: Relationships
Relationships sets
Entity sets are represented as relational schema are shown in Fig. 3.6.
Comparison Operators
(a) < Less than
(b) > Greater than
(c) = Equal to
(d) Not equal to
(e) Lessthan or equal to
(f) Greaterthan or equal to
(g) use boolean operator “not” to negate a condition.
Select the tuples of salary less than 3the 0000 from the instructor relation
𝝈𝑺𝒂𝒍𝒓𝒚 𝒊𝒏𝒔𝒕𝒓𝒖𝒄𝒕𝒐𝒓
Introduction to DBMS: Theory & Practicals 75
Projection Operation
It is a unary operation. Works on single relation and that returns argument relation.
List all attributes ID, name, and salary from instructor relation.
𝝅 𝑰𝒅,𝒏𝒂𝒎𝒆,𝑺𝒂𝒍𝒂𝒓𝒚 𝒊𝒏𝒔𝒕𝒓𝒖𝒄𝒕𝒐𝒓
Composition of operations
Retrieve the faculty names in computer science department in instructor relation
Union Operation
Retrieve the list of all courses taught in the even 2020 and odd 2021 semesters from
section relation
Set Difference
Binary operation. It takes input as two relations. denoted by −. It gives the tuples which
do not exist in the second relation and existed in the first relation.
The expression
r – s, gives an output relation having tuples in r not in s.
Example: Courses offered in even semester 2020 not in odd 2022.
Cartesian-Product Operation
The Cartesian product of relations r and s denoted as r× s. it used to combined at a from
two relations.
Introduction to DBMS: Theory & Practicals 76
Let A and B are two relations, then AXB will get the resultant relation as illustrated in
Fig. 3.11 and 3.12.
Fig. 3.11. Relations A and B with sample data, and AXB resultant relation without
projection and selection
Fig. 3.12. Cartesian-Product Operation AXB resultant relation with selection and
projection
Introduction to DBMS: Theory & Practicals 77
Natural-Join Operation
Relational calculus is implemented at two levels such as tuple and domain. These are non-
procedural query languages.
Introduction to DBMS: Theory & Practicals 78
∀ - “ for all”
∀ t ∈ r (Q(t)) - Q(t) is true “for all” tuples t in relation r.
Example: Use TRC to select the facultyID, name, deptname, salary of faculty
whose salary is more than 65,000/-.
where x1, x2, . . . , xn represent domain variables. P signifies a formula of atoms, as was
the case in the tuple relational calculus. An atom in the domain relational calculus
has one of the following forms:
< x1, x2,x3,x4 . . ….. , xn >∈ r, where r is a relation on n attributes and x1, x2, .
. . , xn are domain variables or constants.
x OP y, where x and y are domains and OP is a operator
(<, ≤, =, _=, >, ≥).
{< f, fn, dt, s > | < f, fn, dt, s >∈ faculty ∧ s > 65000}
Get all facultyIDs of faculty whose salary is more than 65000:
UNIT SUMMARY
• The logical level design of the system provided in relational modeling. Further
this is helpful to the implementation at view level and physical level by using
application programming languages.
• The conceptual design of the database system is provided in E-R and EER
diagrams. Now this is mapped with relational model.
• In relational model:
All entities are represented with tables
Relationships are provided with
Relational data model concepts:
o Domain
o Attribute
o Relation
o Database schema
o Database instance
Database constraints:
o Implicit constraints
o Explicit constraints
o Semantic constraints
The constraints on relational databases are implemented in four ways:
o Domain
o Key
o Entity Integrity
o Referential integrity
Entity Relationship (E-R) model and Enhanced Entity Relationship (EER)
model at conceptual design is mapped with the relational model at the logical
level in three steps:
Step 1: The entity sets with simple and complex attributes
Step 2: Week entity sets
Step 3: Relationship sets
Relational algebra is a procedural query language. It defines a set of operations
such as addition, subtraction, or multiplication.
Introduction to DBMS: Theory & Practicals 81
Π Pi[Projection]
⋈ [Natural join]
X [Cartesian Product]
∪[Union]
EXERCISES
Multiple Choice Questions
1 DRC stands for
a. Data Relational concepts
b. Dependency Relational Calculus
c. Domain Relational Calculus
d. Domain Relational Concepts
2 In Relational Modeling, not related concept
e. domain
f. relation
g. entity
h. attribute
3 In logical design, the ER mapping of entity is
a. constraints
b. table
c. attribute
d. key attribute
4 The domain is not represented one of the following
a. Name
b. data type
c. Constraint
d. File
5 ……..is not a component of a relational database.
a. Entity
b. Hierarchy
c. Table
d. Attribute
6 Inthe usage of DBMS, the vital one is to understand
a. Physical schema
b. All substances that the system supports
c. One sub schema
d. Both (A) and (B)
7 ………….. is not an implicit constraint in relational databases
a. string
b. primary
c. integer
d. float
8 …………. is also called an explicit constraint in relational databases
a. primary key
b. referential integrity
c. schema based integrity
d. semantics
9 String is ……..type of constraint in relational databases
a. key constraint
Introduction to DBMS: Theory & Practicals 83
b. referential integrity
c. domain constraint
d. unique constraint
10 Semantic constraints are implemented through……
a. key constraints
b. data definition language
c. data manipulation language
d. application programming language
11 Projection is ……….type of operation in relational algebra
a. binary
b. unary
c. more relations
d. trinity
12 _______ produces the relation that has attributes of R1 and R2
a. Cartesian product
b. subtraction
c. Product
d. Intersection
13 Cartesian product in relational algebra is
a. Ternary
b. Binary
c. Unary
d. not
14 Predicate in relational calculus is constituted with……….
e. raw facts
f. quantifiers
g. logical operators
h. C&D
15 The tuple relational calculus is proposed by
e. EF Codd
f. kahate
g. James Gossling
h. Dennies Rithchie
16 In the relational modes, cardinality is termed as:
a. No. of tuple’s.
b. No. of attribute’s.
c. No. of table’s.
d. No. of constraint’s
17 Relational calculus is a……………language
a. Procedural.
b. Non- Procedural
c. Data definition.
d. High level.
Introduction to DBMS: Theory & Practicals 84
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
C C C D B C B C C D B A B D A A B C
2. Illustrate the basic structure of relational data model and label the all components.
3. Construct a logical design for a hospital management system with a set of patients and
medical doctors. A patient log containsa history of tests conducted and consultations
made.
5. Identify three possible relations and related attributes that could be utilized to maintain
the attributes of a social networking system like LinkedIn.
7. Identify three possible relations that could be utilized to store data in a social networking
system like Facebook.
Numerical Problems
1.Build the subsequent queries in relational algebra, using the college schema.
a. List the offered courses in the Computer Science department having 4credits.
b. List the RollNos of enrolled students who were handled by afaculty name as Choudhary.
c. List the faculty having salary more than 50000.
2. Consider the employee database. Build queries in tuple relational calculus(TRC) and
domain relational calculus(DRC):
Introduction to DBMS: Theory & Practicals 85
a. Retrieve the employee names who are working for “DBS Bank”.
b. Retrieve the employee names and their residence cities who work for “DBS Bank”.
c. Retrieve the employee names, residence details of street addresses, and city who are
working for “DBS Bank” and earning more than 50000.
Introduction to DBMS: Theory & Practicals 86
PRACTICAL
1. A bank wants to automate each transaction. It provides the subsequent account
types: Fixed Deposit(FD), Recurring Deposit(RD), and Savings Bank (SB)
The Bank also wants to monitor the loans granted to its clients. Identify the relations,
attributes, datatypes and constraints.
Draw the relational schema diagramto provide all explicit constraints. Consider the
following presumptions:
a. A customer is limited to having a single type of account. Joint accounts are not
permitted
b. Only when a consumer has at least one of the account kinds is a loan available.
Use relational algebra for finding
a. account details of all fixed deposits
b. the account details of both fixed deposits and savings bank account
2. To represent the requirements of a small computer business corporation.
Relational model with appropriate domain constraints
Relation 1 - The company workers assemble several computer models. Each
employee's employee number, name, address, phone number, job title, and salary.
Relation 2 - The model, specifications, name, and quantity of each machine.
Relational instance - Each machine is made up of various components. The parts that
are on hand must be listed in an inventory. A record of each part's name, cost, and
available quantity is kept.
Relation 3 - These components are purchased from a number of providers. The
supplier's name, address, and phone number must be kept on file.
use domain relational calculus:
retrieveMORE
KNOW the computer details that have been assembled are sold.
https://www.red-gate.com/simple-talk/databases/theory-and-design/codds-twelve-
Introduction to DBMS: Theory & Practicals 87
Commercial DB systems:
MySQL - www.mysql.com
PostgreSQL - www.postgresql.org
https://nptel.ac.in/courses/106104135
Introduction to DBMS: Theory & Practicals 88
4
d
STRUCTURED QUERY
LANGUAGE(SQL)
UNIT SPECIFICS
RATIONALE
This structured query language unit on Database systems helps students to get knowledge on
programming constructs and commands of SQL and its real-time applications. It provides a
practical relational model using SQL standard for commercial relational DBMSs. It covers the
programming language of SQL with more advanced features of the SQL language for relational
databases including PL/SQL constructs. These constructs helps to users to create, retrieve and
manage database with security.
SQL is an important aspect of commercial database systems that essentially deals with
information and data and their effect on information retrieval. Structured query language (SQL)
statements are started their journey by mathematical functions using calculus and algebra and then
explaining it in terms of relational database management. This permits one to analyze the
operations of many day-to-day transactions around us. Its practical applications are related to the
relational model construction and operation of different types of database systems and tools.
PRE-REQUISITES
Mathematics: Calculus, Algebra (Class XII)
Computer Science: problem-solving with programming (Class XII)
UNIT OUTCOMES
The List of outcomes of this unit is as follows:
U4-O1: Summarize query language constructs and constraints to build database system.
U4-O1: Apply integrity constraints to guard traits and build database system.
U4-O2: Build queries to create, manage and retrieve data from database systems using commercial
databases.
U4-O3: Create queries for efficient data retrieval by using SQL commands and clauses.
U4-O4: Use structured programming for providing security and authentication to the systems
EXPECTEDMAPPINGWITHSUBJECTOUTCOMES
Unit-4 (1-Weak Correlation;2-Medium correlation;3-Strong Correlation)
Outcomes
CO-1 CO-2 CO-3 CO-4 CO-5 CO-6
U4-O1 3 1 3 - - -
U4-O2 1 1 1 - - -
U4-O3 2 2 3 - - -
U4-O4 3 3 3 - - -
U4-O5 3 3 3 - - -
Introduction to DBMS: Theory & Practicals 90
Example:
In the schema of branch relation, 3 attributes – bname, location, and bud_amount; the
domains are a string of a maximum of 18 and 20 characters and numeric of a maximum
of 10 digits of the total in which 2 are decimals; integrity constraint is a primary key
attribute as bname. A semicolon indicates the end of the SQL statement.
In SQL, the insert into statement for inserting values to table in database.
In SQL, the select statement for retrieving data values from table in database.
Example:
In SQL, the update statement for changing data values in a table in database.
SET clause is used to specify the change on attribute with new values.
Example:
update of student record rno 210 with new values marks 25 and contact no.
5555456790
update student SET smarks = 25, contact = 5555456790 WHERE Rno = 210;
In SQL, the delete statement for deleting data values in a table in database.
Example:
Example:
4.3. CONSTRAINTS
Constraints of the database are termed Integrity constraints, domain constraints, referential
constraints, and data constraints.
4.3.1. INTEGRITY CONSTRAINTS:
The integrity constraints(IC) will protect the database from being accidentally damaged
and ensure that the approved changes should not cause a data inconsistent.
Example:
Integrity constraints include primary key, foreign key, and not null.
Primary Key: Is having the property of not null and unique. It assures, the relation does
not exist any tuples has a null value for a primary key attribute; and any two tuple
values have the same value for a primary key attribute. A multicolumn (attribute)
primary key is called a composite key.
Introduction to DBMS: Theory & Practicals 95
The general form of adding primary key (create table at the end of attribute list):
create table r (A1 D1, A2 D2, ..., An Dn, primary key (A1 , A2 ,..., An));
Example:
The dept attribute of the section relation should ensure not null and unique in all the
tuples in the relation department.
create table dept(dname varchar(12), primary key (dname));
Foreign key: It establishes the relationship among tables. The values of attributes should
assure any tuple in the relation must correspond to the values of the primary key
attribute of some tuple in another relation.
The general form of adding primary key (create table at the end of attribute list):
create table r1 (A1 D1, A2 D2, ..., AnDn, foreign key (A1, A2,...,An )references r2);
***r2(A1, A2,...,An) is a already created relation and having values.
The dept attribute of the section relation should ensure the corresponding value
existed in any of the tuples in the relation department.
The dept attribute of the section relation should ensure not null and unique in all the
tuples in the relation department.
create table section(dept varchar(10), foreign key (dept) references department);
here department is existing relation having dept attribute as the primary key.
create table department(dept varchar(10), primary key (dept));
Not null: It does not allow a null value for that attribute.
Example:
The Faculty_name attribute of the faculty relation has not null constraint.
It ensures that the faculty_name of an instructor cannot be a null value.
Create an employee id data type with a name e_type of numeric data type of length 6
digit length. And use e_type for creating attributes of employeeid, mgr_id.
Crete domain e_type As numeric(6);
employeeid e_type;
mgr_id e_type;
phone_no integer;
988776434
No decimal part is included in the value.
Denoted as numeric(p,d)
Example:
salary numeric(10,2);
98765432.98
10000000000.34
The salary attribute defines with a maximum of 10 digits and two precision values.
Real and double precision are types of floating point numbers whose precision levels
depend on the machine.
Float(n) is a floating point number with n precision values.
String Data:
The specific data types to handle string type of data include char and varchar and CLOB
Char stores fixed-length type of strings.
Example:
Name char(10);
Name = Niya
It stores by appending 6 spaces to the name Niya.
Varchar:
Varchar data type stores variable-length strings.
Example:
Name varchar(10);
Name = Niya
It stores the name as Niya without any spaces(even though it is specified as a length of 10).
Introduction to DBMS: Theory & Practicals 99
CLOB (Character large objects): variable-length string data type. It is used to indicate
the string values with a lot of text, or documents. You can specify the maximum
CLOB length in kilobytes (K), megabytes (M), or gigabytes (G).
Example:
DATE ‘2022-10-27’
Introduction to DBMS: Theory & Practicals 100
TIME: It has at least eight positions and includes HOUR, MINUTE, and SECOND. The
general form of representation: HH:MM:SS
Example:
TIME ‘08:11:57’
Timestamp: It includes both the DATE and TIME fields, along with a min. of six fractions
of seconds and an optional TIME ZONE.
Example:
bstring BIT(5);
bstring = B ‘10101’ ( the value should be preceded by the letter B)
defined as not null. Any expression that contains a null value will also return null.
For instance, 30 times null results in null.
UNIQUE key constraint: used to make sure that each record's column of data has unique
information. More than one unique key may be present in a table.
Example:
Create an employee schema with details of contact number, and marital status.
create table employee (employee_id number(5), employee_name varchar(20) not null,
contact_no varchar(10), marital_status char(1) default ‘M’ , primary key
(employee id));
CHECK clause: used to restrict the specified constraint and default values to the attributes.
Introduction to DBMS: Theory & Practicals 102
Example:
The table creation with appropriate integrity constraints of the college database is as
follows::::
Fig. 4.5. SQL data definition of the library management system database
4.4. QUERIES
4.4.1. BASIC STRUCTURE OF QUERY
The basic structure of SQL retrieval query is select-from-where block.
<attribute list> -> list of attribute names whose values
SELECT <attribute list>
are to be retrieved by the query
FROM <table list>
<table list> list of the relation names required to process
WHERE <condition>;
the query.
<condition> A conditional phrase that identify the tuples to be retrieve by the query.
Introduction to DBMS: Theory & Practicals 106
Natural Join: It operates on two tables and produces a table as the result. It considers the
pairs of tuples having both attributes in both tables with the same value.
Inner Join - returns the identical rows from both the tables.
Outer Join- performed in three ways - Left, Right, and Full outer joins
Example:
All faculty, who teaches some Subject in the college, find their names and the
Subject_ IDs of all Subjects they taught.
select faculty_name, Subject_id from faculty, teach where faculty.ID= teach.ID;
Table renaming: table name referred with alias name using as clause
List the name of all faculty whose salary is more than at least one faculty in the CSE
department
select distinct F.faculty_name from Faculty as F, Faculty as CS where F.salary >
CS.salary and CS.dept name = ‘CSE’;
Introduction to DBMS: Theory & Practicals 108
STRING OPERATIONS
SQL provides various string-handling functions on character strings:
1. Concatenating (use symbol “||”)
2. extract sub-strings
3. Find the string length
4. Convert strings to uppercase (use upper(s) where s is a string) and lowercase (use
lower(s))
5. Remove spaces at the end of the string (using trim(s))
Example: Pattern matching using like operator and string with special characters
List all subjects offered either in even 2009 or in odd 2010, or both.
(select Subject_id from section where semester = ’odd’ and year= 2021)
union
(select Subject_ id from section where semester = ’even’ and year= 2022);
Introduction to DBMS: Theory & Practicals 111
Intersect
Example:
List all Subjects taught in the odd 2021 as well as in even 2022.
(select Subject_id from section where semester = ’odd’ and year= 2021)
intersect
(select Subject_id from section where semester =’even’ and year= 2022);
Except Operation
The except performs set difference. It outputs all rows from its first relation that does not
occur in the second relation.
Example:
List all Subjects taught in the odd 2021 but not in even 2022.
(select Subject_ id from section where semester = ’odd’ and year= 2021)
except
(select Subject_id from section where semester =’even’ and year= 2022);
IN /NOT IN
in / not in constrains for performing the tests on the set along with select.
Example:
Find the average salary of those branches where the average salary is greater than
65000/-
select B_name, avg (salary) from (select B_name, avg(salary) from faculty group
by B_name) as Branch_avg_sal (B_name,avg(salary)) where Avg_salary > 65000;
Find the maximum salary across all branches total salary at each branch.
select max (Tot_salary)
from (select B_name, sum(salary) from faculty group by B_name) as branch_total
(B_name, Tot_salary);
4.5. VIEWS
SQL views provide a virtual table, which is dynamically constructed for a user-specific by
extracting data from base table(s). It is a custom-made representation of the data
Introduction to DBMS: Theory & Practicals 113
contained in one or more table(s) / view(s). It takes the output of a query and creates
a table; therefore, it is a stored query or a virtual table. It provides further security to
the tables by restricting access to the existing data from a table. It provides a
simplified query structure to the user and hides the data complexity.
Why views:
To simplify queries
Similar to the queried from a base table
Gives extended data security
Create - view
Example:
updating a view:
In general, views are readable. To perform data manipulation at views it should pass to the
respective table.
To make views updatable, they should meet the following criterion:
Only one table may be used to generate it.
The view needs to contain the table's primary key column.
The select statement does not allow the use of aggregate functions.
A Distinct, Group by, or Having clause should not be present in the select statement
used to create a view.
Introduction to DBMS: Theory & Practicals 114
Subqueries should not be utilized in the select statement used to create a view.
It can't employ value expressions like total / 5 or constants, strings, or constants.
Example:
Retrieve data from view - List all the titles of books written by author ‘Sanjay.
select book_title from V_book where book_title = ‘Sanjay’;
Dropping a view - delete a view V_Book
Drop view V_Book
4.6. SECURITY
Assigning a user's privileges to parts of the database is called authorization. Authorizations
on data may contain reading, inserting new data, updating data, and deleting data.
Granting or revoking
SQL data definition language (DDL) provides a set of commands like grant, revoke to
confer, and revoke privileges. The grant statement is used to confer authorization.
The SQL provides the privileges of select, insert, update, and delete. The privilege type
‘all privileges’ can be used for all the allowable privileges.
Example:
Introduction to DBMS: Theory & Practicals 115
Example: Give authorization to Mr. Roi and Head_est for an update on the salary attribute
of the salary_master relation:
grant update (salary) on salary_master to Roi, head_est;
remove update privilege from rai on salary master table
revoke update (salary) on salary_master to Roi, head_est;
Advantages of PL/SQL:
SQL is the industry-standard database language, and PL/SQL and SQL are tightly
interconnected.
Both static and dynamic SQL are supported by PL/SQL.
DML operations and transaction control from PL/SQL blocks are supported using static
SQL. PL/SQL blocks can contain DDL statements when using Dynamic SQL.
Introduction to DBMS: Theory & Practicals 116
PL/SQL enables batching of statements to be sent to the database. This lowers network
traffic and gives the applications exceptional performance.
PL/SQL allows programmers to query, manipulate, and update data in a database, due
to this it increases programmers' productivity.
Strong features like exception handling, encapsulation, data hiding, and object-oriented
data types in PL/SQL reduce design and debugging time.
PL/SQL applications are completely portable.
It offers a high level of security.
Access to preconFig.d SQL packages is provided.
It offers assistance in Object-Oriented Programming for creating Server Pages and Web
Applications.
Declaration section - Used to specify variables, structures, and data types. Give names,
data types, and starting values when declaring variables.
Introduction to DBMS: Theory & Practicals 117
Execution section - Used to insert code or logic into block structures; at least one statement
is required. It starts with the term BEGIN. The execution portion contains both
procedural and SQL statements.
Exception section: Used to handle exceptions through either catch or handle.
Example:
Named Block:
A named block is a specific kind of block that begins with the header section, which
identifies the block's name and kind. These come in two varieties: procedures and
functions.
Header
IS
Declaration section
BEGIN
EXCEPTION
Exception section
END;
Fig. 4.8. General block structure of PL/SQL
Introduction to DBMS: Theory & Practicals 118
Header - Used for named blocks. Which are called by name, parameter list, and return
clause (for functions)
Generate output from - DBMS_OUTPUT is a built_in package that is used to display the
output, and debugging information, and send messages from PL/SQL blocks,
subprograms, packages, and triggers.
Example:
The list of operators used in programming and their precedence is given in Table.
Arithmetic operators +,-,*,/,** (Exponentiation)
Relational operators = , !=, >, <, <=, >=
Comparison Operators LIKE, BETWEEN, IN
Logical Operators and, or, not
The precedence of operators goes as follows:
=, <, >, <=, >=, <>, !=, ~=, ^=, IS NULL, LIKE, BETWEEN, IN.
4.7.3. SEQUENCES
A sequence is an object in Oracle that is used to generate a number sequence. This can be
useful when you need to create a unique number to act as a primary key.
Create Sequence:
Introduction to DBMS: Theory & Practicals 119
Example:
DROP sequence
Example:
Example:
Demo of a simple IF-THEN Statement
DECLARE
performance NUMBER(8,2) := 1010
base NUMBER(8,2) := 10000;
increment NUMBER(6,2);
fid NUMBER(6) := 120;
BEGIN
IF performance > (base + 200) THEN
increment:= (sales - quota)/4;
UPDATE employees SET salary = salary + increment WHERE emp_id = fid_id;
END IF;
END;
/
A demo on case-when statement
DECLARE
gradepoint CHAR(1);
BEGIN
gradepoint := ‘B’;
CASE gradepoint
WHEN ‘A’ THEN DBMS_OUTPUT.PUT_LINE(‘Excellent’);
WHEN ‘B’ THEN DBMS_OUTPUT.PUT_LINE(‘Very fair’);
WHEN ‘C’ THEN DBMS_OUTPUT.PUT_LINE(‘fair);
WHEN ‘D’ THEN DBMS_OUTPUT.PUT_LINE(‘good’);
WHEN ‘F’ THEN DBMS_OUTPUT.PUT_LINE(‘fail’);
ELSE DBMS_OUTPUT.PUT_LINE(‘No grade’);
END CASE;
END;
EXIT-WHEN
EXIT– unconditionally stops the iterations.
WHEN conditionally stop the loops.
FOR-LOOP
Example:
A demo on for loop
DECLARE
n NUMBER := 0;
BEGIN
FOR r IN 1..100 LOOP — generate a sequence of 100 terms
n := n + (r**2);
END LOOP;
DBMS_OUTPUT.PUT_LINE( ‘sum of sequence : ‘ || n );
END;
4.7.5. CURSORS
A cursor is a pointer to the context area. A cursor holds the rows (one or more) returned
by a SQL statement. The set of rows the cursor holds is referred to as the active set.
There are two types of cursors “
• Implicit cursors
• Explicit cursors
Implicit cursors - automatically created by Oracle whenever an SQL statement is executed,
when there is no explicit cursor for the statement. Whenever a DML statement
(INSERT, UPDATE, and DELETE) is issued, an implicit cursor is associated with
this statement. For INSERT operations, the cursor holds the data that needs to be
inserted. For UPDATE and DELETE operations, the cursor identifies the rows that
would be affected. In PL/SQL, the most recent implicit cursor, always has attributes
such as %FOUND, %ISOPEN, %NOTFOUND, and %ROWCOUNT.
Introduction to DBMS: Theory & Practicals 122
Attribute Returns
%FOUND TRUE if an INSERT, UPDATE, or DELETE statement affected
one or more rows or a SELECT statement returned one or more
rows.
Else FALSE
%NOTFOUND TRUE if an INSERT, UPDATE, or DELETE statement
affected no rows, or a SELECT statement returned no rows.
%ISOPEN FALSE for implicit cursors
Example:
illustration of cursor, that will update the table and increase the salary of each
faculty by 5000 and use the SQL%ROWCOUNT attribute to determine the
number of rows affected.
DECLARE
no_row number(2);
BEGIN
UPDATE faculty
SET salary = salary + 5000;
IF sql%notfound THEN
dbms_output.put_line(‘no facylty selected’);
ELSIF sql%found THEN
no_row := sql%rowcount;
dbms_output.put_line( total_rows || ‘facylty selected’);
END IF;
END;
/
Explicit Cursors:
Explicit cursors are programmer-defined cursors for gaining more control over the
context area. An explicit cursor should be defined in the declaration section of the
Introduction to DBMS: Theory & Practicals 123
PL/SQL Block. It is created on a SELECT Statement which returns more than one
row.
Example
illustration of explicit cursor
DECLARE
s_id students.id%type;
s_name students.No.ame%type;
s_addr students.address%type;
CURSOR c_ students is
SELECT id, name, address FROM students;
BEGIN
OPEN c_ students;
LOOP
FETCH c_ students into c_id, c_name, c_addr;
EXIT WHEN c students %notfound;
Introduction to DBMS: Theory & Practicals 124
4.7.6. TRANSACTIONS
A database transaction is an atomic unit of work that may consist of one or more related
SQL statements.
Transaction operation Description
Example:
Illustration of the transaction on emp table.
INSERT INTO EMP (EID,ENAME, AGE, E_ADDRESS, SALARY)
VALUES (12, ‘Roi, 39, ‘LP’, 19500 );
INSERT INTO EMP (EID, ENAME, AGE, E_ADDRESS, SALARY)
VALUES (18, ‘Rini, 25, ‘Wall’, 55000 );
SAVEPOINT save1;
UPDATE EMP
SET SALARY = SALARY + 10000;
ROLLBACK TO save1;
UPDATE EMP
SET SALARY = SALARY + 10000
WHERE ID = 18;
UPDATE EMP
SET SALARY = SALARY + 5000
WHERE ID = 12;
COMMIT;
*** ROLLBACK TO save1: rolls back all the changes up to the point, where you had
marked savepoint save1.
Introduction to DBMS: Theory & Practicals 125
FUNCTIONS
The general form of creating a function:
CREATE [OR REPLACE] FUNCTION function_name
[(parameter_name [IN | OUT | IN OUT] type [, ...])] RETURN
return_datatype
{IS | AS}
BEGIN
< function_body >
Example:
Illustration of creating a function.
CREATE OR REPLACE FUNCTION total faculty
RETURN number IS
total_faculty number(2) := 0;
BEGIN
SELECT count(*) into total_faculty
FROM faculty;
RETURN total_faculty;
END;
/
System-defined exceptions
User-defined exceptions
Example:
Introduction to DBMS: Theory & Practicals 128
4.7.9. TRIGGERS
Triggers are stored programs, which are automatically executed or fired when some events
occur. Triggers are, written to be executed in response to any of the following events:
database manipulation statement (DELETE, INSERT, or UPDATE)
database definition statement (CREATE, ALTER, or DROP).
database operation (SERVER ERROR, LOGON, LOGOFF, STARTUP, or
SHUTDOWN).
Triggers can be defined on the table, view, schema, or database with which the event is
associated.
Benefits of Triggers:
Triggers can be written for the following purposes “
Generating some derived column values automatically
Enforcing referential integrity
Event logging and storing information on table access
Auditing
Introduction to DBMS: Theory & Practicals 129
Example:
Illustration of the trigger on employee table
CREATE OR REPLACE TRIGGER alert_salary_changes
BEFORE DELETE OR INSERT OR UPDATE ON employee
FOR EACH ROW
WHEN (NEW.ID > 0)
DECLARE
salary_diff number;
BEGIN
salary_diff := :NEW.salary - :OLD.salary;
dbms_output.put_line(‘Old salary: ‘ || :OLD.salary);
dbms_output.put_line(‘New salary: ‘ || :NEW.salary);
dbms_output.put_line(‘Salary difference: ‘ || salary_diff);
END;
Introduction to DBMS: Theory & Practicals 132
UNIT SUMMARY
VIEWS
SQL view is a virtual table, which is dynamically constructed for a user-specific by
extracting data from base table(s). operation on views are:
Create a view, updating a view, Selecting data from a view, and Dropping a view
SECURITY
Assigning a user's privileges to parts of the database is called authorization.
Authorizations on data may include, reading, inserting new data, updating
data, and deleting data.
Granting or revoking
SQL data definition language (DDL) provides a set of commands like grant, revoke
to confer, and revoke privileges. The grant statement is used to confer
authorization. To revoke an authorization, SQL provides a revoke keyword.
SQL provides the privileges of selecting, inserting, updating, and deleting.
SQL PROGRAMMING TECHNIQUES - The PL/SQL programming language
as a procedural extension language for SQL was developed by Oracle
Corporation in the late 1980s available as an Oracle database.
PL/SQL – OPERATORS
The list of operators used in programming - Arithmetic operators, Relational
operators, Comparison Operators, Logical Operators
SEQUENCES
A sequence is an object in Oracle that is used to generate a number sequence. This
can be useful when you need to create a unique number to act as a primary key.
Operations are: Create Sequence and DROP sequence
PL/SQL CONTROL STRUCTURES
Testing Conditions: IF and CASE Statements. There are three forms of IF
statements: IF-THEN, IF-THEN-ELSE, and IF-THEN-ELSIF
LOOP- END LOOP – control statement
EXIT-WHEN [EXIT– unconditionally stops the iterations.
WHEN conditionally stop the loops.] and FOR-LOOP
EXERCISES
Multiple Choice Questions
1 SQL stands for
a. semantic query language
b. stored query language
c. structured query language
d. self query language
2 .........................commands are used to create a table, index, or view.
i. domain
j. create
k. DDL command
l. attribute
3 The .......................... supported by SQL are used to define domain constraints of
attributes.
a. data types
b. integrity constraints
c. column names
d. key attributes
4 The attribute holding the values as not null and unique, then it is termed as
.................. key attribute
a. REFERENTIAL
b. NOT NULL constraint
c. NULL
d. PRIMARY
5 The table having more than one attribute as the primary key, then it is termed
as……...
a. primary key
b. foreign key
c. composite key
Introduction to DBMS: Theory & Practicals 138
d. referential key
6 In the usage of the foreign key, the attribute should possess the property of
...................
a. primary key in referential table
b. not null in referential table
c. should possess same data type in both tables
d. ALL
7 The database system has several virtual schemas according to the level of
..........................
a. user interest
b. abstraction
c. concise view
d. none
8 ............................... keyword is used to specify a condition
a. where
b. group
c. IN
d. from
9 ............................... keyword is used to perform grouping.
a. where
b. group BY
c. IN
d. from
10 The ............................. is used to insert rows or add a new row of data into the
existing table or view.
a. alter
b. insert
c. select
d. create
Introduction to DBMS: Theory & Practicals 139
Numerical Problems
1. Build the subsequent queries in SQL, using the customer's schema.
a. List the offered products in the sore in electronics category items related to laptop.
b. List the customer names whose last name with Choudhary.
c. List the customers having income more than 60000.
2. Consider the employee database. Build queries using SQl and PL/SQL programming
a. Retrieve the employee names who are working for “DBS Bank” and staying in the city
‘hyderabad’.
b. Create a sequence of customer numbers with a pattern of category name and sequence
numbers. Example: ELEC001 starts for electronics category customers.
c. create a trigger to alert the updation in a salary and maintain a salary history table on
each update.
Introduction to DBMS: Theory & Practicals 141
PRACTICAL
Commercial DB systems:
MySQL - www.mysql.com
PostgreSQL - www.postgresql.org
FUNCTIONAL
5
d
DEPENDENCIES AND
NORMALIZATION FOR
UNIT SPECIFICS
RATIONALE
The objective of relational database design is to develop a collection of relation schemas that
allows us to store information without redundancy while allowing facilitates its retrieval. The
relational database is made up of various schemas, each of which has a number of attributes. We
had assumed up until this point that attributes are organized into relational groups using the
database designer's common sense or by translating a conceptual data models like ER or
enhanced-ER (EER) models, into a database schema design. Using these models the identification
of entities, relationships, and associated attributes, and the mapping processes covered in Chapter
3 result in a logical combination of the attributes into relations. We still need a formal method,
though; to examine the grouping of attributes into a relation schema could be preferable to another.
In Chapters 3 focus on the database design, we did not create any appropriateness or goodness
metrics to assess the design's quality outside of the designer's intuition. In this chapter, we go
through some of the theory that has been created to assess the design quality of relational schemas,
or to quantify why one set of attribute groupings into relation schemas is preferable to another.
The quality of relational schemas can be discussed on two different levels. In the first, users'
interpretations of relation schemas and the significance of their properties are expressed at a
logical (or conceptual) level. Good relation schemas at this level allow users to accurately build
their queries by helping them comprehend the meaning of the data in the relations. The second
level refers to the physical storage (or implementation) of the base relation's tuples. The concept
of identification of functional dependencies, a formal constraint among attributes that serve as the
primary technique for formally evaluating the suitability of attribute groups into relation schemas,
is the focus of this chapter. We talk about normal forms and how normalizing works by employing
functional dependencies. A set of desirable constraints described by primary keys and functional
dependencies are used to define successive normal forms. The normalization process entails
conducting a succession of tests on relations to ensure that they satisfy these progressively
demanding specifications and, when necessary, decomposing the relations. Discuss normal
forms(from 1NF to 5NF) that can be used to analyze any design without the need for meticulous
examination and normalization. Covers extended topics like multivalued dependency and join
dependency.
Databases are an important branch of computer science that essentially deals with information
and data and their effect on information retrieval. Database system implementation needs as a
prerequisite step in data modeling and it is termed relational database management. This permits
one to analyze the operations of many day-to-day transactions around us. Its practical applications
are related to the model, construction, and operation of different types of database systems and
tools.
PRE-REQUISITES
Mathematics: Calculus, Algebra (Class XII)
Computer Science: problem-solving with programming (Class XII)
Introduction to DBMS: Theory & Practicals 145
UNIT OUTCOMES
Further dependencies
The List of outcomes of this unit is as follows:
U5-O1: Identify the functional dependencies in databases.
U5-O2: Summarize the various normal forms in the normalization of databases.
U5-O3: Make use of normal forms to remove the dependencies in databases
U5-O4: Outline the database design algorithms.
EXPECTEDMAPPINGWITHCOURSEOUTCOMES
Unit- (1-WeakCorrelation;2-Mediumcorrelation;3-StrongCorrelation)
1Outcomes
CO-1 CO-2 CO-3 CO-4 CO-5 CO-6
U5-O1 2 2 3 - - -
U5-O2 2 2 2 - - -
U5-O3 3 3 3 - - -
U5-O4 3 3 3 - - -
Introduction to DBMS: Theory & Practicals 146
The relational schema design quality is measured by using four informal guidelines:
1. Create a relational schema that is simple to interpret. A single relation should not have
properties from several entity types and relationship types. It makes sense intuitively
that a relation schema's meaning can be easily explained if it corresponds to just one
entity type or one type of relationship. Otherwise, semantic ambiguities may arise
and the relationship will be difficult to understand if it refers to a combination of
different entities and relationships.
2. Make that there are no insertion, deletion, or modification abnormalities when creating
the base relation schemas. Construct the processes without any sort of anomalies
while updating the database.
3. Avoiding attributes with NULL values in a base relation. If NULLs are inevitable, ensure
that in exceptional cases and do not affect the majority of the tuples in the relation.
4. Create relational schemas joined on equality condition on correctly related attribute pairs
(primary key, foreign key) in a way that ensures no erroneous tuple(s) are produced.
Keep away from combining on relation schemas with matching attributes that aren't
(foreign key, primary key) combinations, as doing so could result in erroneous tuples.
Division
Project
Employee_Member
Division
Fig. 5.2 explains a state of the schemas of industry database. The relational schema
guidelines are accommodated in the design of database.
In the schema definition, the attribute semantics are clear - All these schemas are
defined with clear semantics.
Minimising the redundant data in tuples – The goal of relational schema design is
minimising the space of storage with minimal no. of attributes grouped to the relation.
Storing join relation leads to the anomalies like insert, update and delete. Here all schemas
grouped with appropriate set of attributes, so no chances of anomalies.
Minimising the NULL values in tuples – with NULL value attributes, many problems
may rise like improper understanding on join operation, wastage of space, problem to
perform aggregation operations (count, sum, average), when join and select on condition
are performing, the results are unpredictable. All tuples are accommodated with relevant
values. Hence no NULL value issue existed.
Not allowing the chance of generating erroneous tuples – While performing join on non
key attribute tables, then leads to erroneous tuples. Here all tables are accommodated with
primary key attribute. Hence no design issue existed.
Example: Consider the relation schema Employee-Project shown in Fig. 5.2. from
the semantics of the attributes and the relation, the functional dependencies
identified are:
i. emp_no → Emp_name
ii. Proj_no → {Proj_name, Proj_location}
iii. { emp_no, Proj_no } → months_worked
2. A sequence of tests called normal forms that may be run on specific schemas to
allow for any desired level of normalization of the relational database.
Normal form: Codd has proposed three normal forms, which are based on an
mathematical (analytical) tool called functional dependency among the attributes of
a relation. These are termed as first normal form(1NF), second normal form(2NF),
and third normal form(3NF). Later Boyce and Codd were proposed with a strong
definition of 3NF and termed as Boyce-Codd normal form (BCNF). Further two more
normal forms are proposed as a fourth normal form (4NF) based on the multivalued
dependencies and a fifth normal form(5NF) on join dependencies.
5.3.1. FIRST NORMAL FORM (1NF)
First normal form (1NF), which was designed to prevent attributes having values like
multi-valued, composite, and their combinations, is the formal specification of a
relation in the fundamental (flat) data model. It specifies that an attribute value must
be atomic (means simple, and indivisible) and each tuple have a single value of same
domain. As a result, 1NF prevents the attribute values from a set of multiple, a tuple,
or a combination of both. The attribute values of single atomic (or indivisible) are
permitted by 1NF.
Example: Consider the division schema shown in Fig. 5.3, whose primary key is
Div_No, and Office locations attribute. Assume that each division is accommodated
at multiple locations. The division schema sample state illustrates that not in 1NF
since Office locations attribute value is not in an atomic state, as exemplified by the
first and second tuples.
Division_schema
1. Set F := E.
2. Replace each functional dependency X → {A1, A2, … , An} in F by the n functional
dependencies X →A1, X →A2, … , X → An. (*This places the FDs in a canonical
form for subsequent testing*)
3. For each functional dependency X → A in F for each attribute B that is an element of X
if { {F − {X → A} } ∪ { (X − {B} ) → A} } is equivalent to F
then replace X → A with (X − {B} ) → A in F.
(*This constitutes removal of an extraneous attribute B contained in the left hand side
X of a functional dependency X → A when possible*)
4. For each remaining functional dependency X → A in F
if {F − {X → A} } is equivalent to F,
then remove X → A from F.
(*This constitutes removal of a redundant functional dependency X → A from F
when possible*)
5.4.3. FINDING KEY OF A RELATION
Algorithm 3: Finding a Key K for R Given a Set F of Functional Dependencies
Input: A relation R and a set of functional dependencies F on the attributes of R.
1. Set K := R.
2. For each attribute A in K
{compute (K − A)+ with respect to F;
if (K − A)+ contains all the attributes in R, then set K := K − {A} };
Definition. An inclusion dependency R.X < S.Y between two sets of attributes - X of
relation schema R, and Y of relation schema S - specifies the constraint that, at any
specific time when r is a relation state of R and s is a relation state of S, we must have
πX(r(R)) ⊆ πY(s(S))
Here, it is not necessarily have to be a proper subset. Obviously, the sets of attributes on
which the inclusion dependency is specified -X of R and Y of S - must have the same
number of attributes. In addition, the domains for each pair of corresponding
attributes should be compatible.
5.5.2. BASED ON ARITHMETIC FUNCTIONS AND PROCEDURES
The attributes of a relation may be related via some arithmetic function or a more
complicated functional relationship. As long as a unique value of Y is associated with
every X, we can still consider that the FD X → Y exists.
Example: ORDER_Record (Order#, Item#, Quantity, Unit_price, Extended_price,
Discounted_price)
In this relation, (Quantity, Unit_price ) → Extended_price
FD is existed by the formula Extended_price = Unit_price * Quantity
Introduction to DBMS: Theory & Practicals 168
UNIT SUMMARY
Closure Algorithm
EXERCISES
Multiple Choice Questions
1 Identify a TRUE statement?
A. Every relation in 3NF is also in BCNF
B. A relation R is in 3NF if every non-prime attribute of R is fully functionally dependent
on every key of R
C. Every relation in BCNF is also in 3NF
D. No relation can be in both BCNF and 3NF
2 Consider a relational table for student details with a single record for each registered
student having the set of Attributes.
1. Roll_ Numer: Unique registration number of each admitted student
2. AADHAAR_Id: A Unique identity number, unique at the national level for each citizen
3. Bank Acc_ Number: Unique account number in the bank. A student can have multiple
accounts or joint accounts. This attribute provisions the primary account number.
4. Name: Name of the student
5. Hostel_ Room: Room number of the hostel
Which one of the following option is INCORRECT?
A. Bank Acc_ Number is candidate key
B. Roll_ Number can be a primary key
C. AADHAAR_Id is candidate key if all students are from the same country
D. If S is a super key such that S∩ AADHAAR_Id is NULL then S∪ AADHAAR_Id is
also a super key
3 The normal form which satisfies multi valued dependencies and which is in BCNF
is
A. 4 NF
B. 3 NF
C. 2 NF
D. All of the mentioned
Introduction to DBMS: Theory & Practicals 170
possible
C. Lossless, dependency-preserving decomposi-tion into BCNF is
always possible
D. Any relation with two attributes is in BCNF
8 In the __________ normal form, a composite attribute is converted to individual
attributes.
A. First
B. Second
C. Third
D. Fourth
9 A table on the many side of a one to many or many to many relationship must:
A. Be in Second Normal Form (2NF)
B. Be in Third Normal Form (3NF)
C. Have a single attribute key
D. Have a composite key
10 Tables in second normal form (2NF):
A. Eliminate all hidden dependencies
B. Eliminate the possibility of a insertion anomalies
C. Have a composite key
D. Have all non key fields depend on the whole primary key
11 Which-one of the following statements about normal forms is FALSE?
A. BCNF is stricter than 3 NF
B. Lossless, dependency -preserving decomposition into 3 NF is always
possible
C. Loss less, dependency – preserving decomposition into BCNF is
always possible
D. Any relation with two attributes is BCNF
12 Functional Dependencies are the types of constraints that are based on______
A. Key
Introduction to DBMS: Theory & Practicals 172
B. Key revisited
C. Superset key
D. None of the mentioned
13 Which is a bottom-up approach to database design that design by examining the
relationship between attributes:
A. Functional dependency
B. Database modeling
C. Normalization
D. Decomposition
14 Which forms simplifies and ensures that there is minimal data aggregates and repetitive
groups:
A. 1NF
B. 2NF
C. 3NF
D. All of the mentioned
15 Which forms has a relation that possesses data about an individual entity:
A. 2NF
B. 3NF
C. 4NF
D. 5NF
16 Which forms are based on the concept of functional dependency:
A. 1NF
B. 2NF
C. 3NF
D. 4NF
17 Empdt1(empcode, name, street, city, state,pincode).
For any pincode, there is only one city and state. Also, for given street, city and state,
there is just one pincode. In normalization terms, empdt1 is a relation in
A. 1 NF only
Introduction to DBMS: Theory & Practicals 173
Answers to MCQs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
C A A A B D C A D A C A C C C C A C
2. Discuss normalization?
6. Imagine creating a video portal that is similar to YouTube. Think of the data in a system
for processing files. Describe how each of these elements relates to the storage of
actual video data as well as to the information that describes the video, such as the
title, the user who uploaded it, tags, and the users who watched it.
7. Illustrate a relational database design for a hospital management system with a set of
patients and medical doctors. A patient log contains a history of tests conducted and
consultations made.
Introduction to DBMS: Theory & Practicals 174
8. Design a relational database for maintaining a track of the sports team based on interest.
Then a system should store the matches played, the scores in each match, the players
in each match and individual player statistics for each match. Summary statistics
should be accommodated as derived attributes.
d. Assume {Author, Title} is the key for both schemes. Apply the appropriate normal
form for Book and Cancellation?
Numerical Problems
1.It has been determined by Amazon.com to rearrange its database. Books, sales, and user
data are all stored. Amazon collects as much data as it can on user behaviour so that
it can analyse it and make site improvements. Here are a few prerequisites:
(a) Each user is assigned a special ID, name, password, and email address. Amazon
emails consumers on a regular basis, thus it's crucial to know if the user is okay with
being spammed and if their email address has been returning messages.
(b) Amazon keeps track of a user's most recent visit date so that it can show the user
a list of products that have been added to the site since his previous visit.
(c) Books are identified by their ISDN number, title, author, publisher, and 2.
According to the above change, illustrate the schema diagram of restructured
columns in the COURSE, SECTION, and PREREQUISITE relations so that only one
column will need to be updated.
Design a relational database schema for the above-mentioned data,
Introduction to DBMS: Theory & Practicals 176
PRACTICAL
1. A bank wants to automate each transaction. It provides the subsequent account
types: Fixed Deposit (FD), Recurring Deposit (RD), and Savings Bank (SB)
The Bank also wants to monitor the loans granted to its clients. Determine the entities,
their properties, and any relationships among them.
Design and create a relational schema using any open-source database systems
(MySQL) and make sure to provide all explicit assumptions. Consider the following
presumptions:
a. A customer is limited to having a single type of account. Joint accounts are not
permitted.
b. Only when a consumer has at least one of the account kinds is a loan available.
KNOW MORE
Introduction to DBMS: Theory & Practicals 179
https://www.geeksforgeeks.org/normal-forms-in-dbms/
.
Course outcomes (COs) for this course can be mapped with the programme outcomes (POs) after
the completion of the course and a correlation can be made for the attainment of POs to analyze
the gap. After proper analysis of the gap in the attainment of POs necessary measures can be taken
to overcome the gaps.
CO-1 3 3 3 3 1 1 3
CO-2 3 2 2 2 1 1 3
CO-3 3 3 3 3 1 1 3
The data filled in the above table can be used for gap analysis.
Introduction to DBMS: Theory & Practicals 182
INDEX
A M
Abstraction 5 Mapping Cardinalities 45
Administrators 11 Multi-Valued 41
Alter Table 94
N
Architecture 16 Naïve Users 12
Null 41
B
BLOB - Binary Large Object 100 Numerical Data 97
Client/Server 20 Predicate 78
Conceptual 14
Q
Conceptual Modeling 37 Query 105
Constraints 45,94
R
Control Structures 119 Real-Time Applications 24
Relation 65
D
Data And Time Data 99 Relational 25
Database 3
S
Default 101 Schema 15, 91
Designers 11 Select 92
SET Clause 93
E
E-Commerce 26 SET Operations 75, 110
For All 78
T
Foreign Key 95 There Exists 78
Integrity 4, 94
V
IS-A Or Or IS-AN Relationship 50 Value Sets 44
Isolation 4 View 5
Views 113
J
JOIN Dependency 160, 162
W
Weak Entity 40
L
Lattices 51
Logical 5
Introduction to DBMS: Theory & Practicals 186