0% found this document useful (0 votes)
6 views108 pages

Mod_1

The document outlines the syllabus for a course on Database Management Systems (DBMS), covering topics such as basic database concepts, data models, and the advantages of using DBMS. It includes learning objectives, course content, and historical developments in database technology. Additionally, it discusses the characteristics of the database approach and the differences between schemas and instances.

Uploaded by

Bindushree Bade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views108 pages

Mod_1

The document outlines the syllabus for a course on Database Management Systems (DBMS), covering topics such as basic database concepts, data models, and the advantages of using DBMS. It includes learning objectives, course content, and historical developments in database technology. Additionally, it discusses the characteristics of the database approach and the differences between schemas and instances.

Uploaded by

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

Data Base Management System

BCS403
MODULE-1

Introduction to Databases

Text Book: Fundamentals of Database Systems, Ramez Elmasri and Shamkant


B. Navathe, 7th Edition, 2017, Pearson. ”

Course Coordinator
Dr Archana R A

Department of Computer Science and Business


3/18/25 1
systems
Agenda

✔ What is DBMS

✔ Applications and Relevance

✔ Course Content and Delivery

✔ Course Outcomes

✔ Program Outcomes and Program


Specific Outcomes

✔ DBMS Course mapped to the


Placement, Higher Studies and
Entrepreneurship

18/03/25
Department of Computer Science and Business
2
systems
Contents
1. Topics of Module-1
2. Learning Objectives
3. Basic Definitions of Database Concepts
4. Database system environment
5. Main Characteristics of the Database Approach
6. Advantages of using the DBMS Approach
7. Historical Development of Database Technology
8. Database Languages and Architectures
9. Schemas versus Instances with examples
10. Conclusion

18/03/25
Department of Computer Science and Business
3
systems
Module-1
Introduction to Databases

18/03/25
Department of Computer Science and Business
4
systems
Topics of Module-1
Introduction to Databases: Introduction, Characteristics of database approach,
Advantages of using the DBMS approach, History of database applications.
Overview of Database Languages and Architectures: Data Models,
Schemas, and Instances. Three schema architecture and data independence,
database languages, and interfaces, The Database System environment.
Conceptual Data Modelling using Entities and Relationships: Entity types,
Entity sets, attributes, roles, and structural constraints, Weak entity types, ER
diagrams, examples, Specialization and Generalization.
10 Hours
Textbook 1:Ch 1.1 to 1.8, 2.1 to 2.6, 3.1 to 3.10
Text Books:
1. Fundamentals of Database Systems, Ramez Elmasri and Shamkant B.
Navathe, 7th Edition, 2017, Pearson.
2. Database management systems, Ramakrishnan, and Gehrke, 3rd Edition,
2014, McGraw Hill

18/03/25
Department of Computer Science and Business
5
systems
Learning Objectives

On Completion of this Module, the learner will be able to:

1. Understand the basic concepts of Database and Evolution of database


2. Understand the Data Models, Schemas, and Instances, Database
system environment
3. Understand the concepts of ER Modelling
4. Apply and draw ER Diagrams for various problem statement

18/03/25
Department of Computer Science and Business
6
systems
Quote for the Day

With data collection, ‘the sooner the better’ is always the best answer.”

- Marissa Mayer
American businesswoman and investor

“You can have data without information, but you cannot have
information without data.”
- Daniel Keys Moran
American computer programmer and science fiction writer

18/03/25
Department of Computer Science and Business
7
systems
Basic Definitions

Data: Raw facts that can be recorded/acquired which has an implicit


meaning. Ex- Age, Color, name..etc

Database: A collection of related data, organized in a proper


manner for effective and efficient storage and retrieval purpose.

Database Management System (DBMS): A software


package/ system to facilitate the creation and maintenance of a
computerized database.

Mini-world (DB - Problem Statement): Some part of


the real world about which data is stored in a database. For example,
student grades and transcripts at a university.

18/03/25
Department of Computer Science and Business
8
systems
Basic Definitions (Cont…)

Database System: The DBMS software together with the


data itself. Sometimes, the applications are also included.
Users/Programmers

Database System

DBMS Software

Stored Data (Meta Data)

Simplified database system environment


18/03/25
Department of Computer Science and Business
9
systems
Main Characteristics of the Database
Approach
There are 5 Main characteristics of the database approach:[SIDSS]

1. Self-describing nature of a database system


2. Insulation between programs and data
3. Data Abstraction
4. Support of multiple views of the data
5. Sharing of data and multi-user transaction processing

1.Self-describing nature of a database system:

• A DBMS catalog stores the description of a particular


database (e.g. data structures, types, and constraints)
• The description is called meta-data.
• This allows the DBMS software to work with different
database applications.

18/03/25
Department of Computer Science and Business
10
systems
Main Characteristics of the Database Approach (
Cont…)
2. Insulation between programs and data:

• It is also called as program-data independence.


• Allows changing data structures and storage organization without
having to change the DBMS access programs.

3. Data Abstraction:

• A data model is used to hide storage details and present the users with a
conceptual view of the database.
• Programs refer to the data model constructs rather than data storage
details
4. Support of Multiple views of the data:
• Each user may see a different view of the database, which describes
only the data of interest to that user.

18/03/25
Department of Computer Science and Business
11
systems
Main Characteristics of the Database Approach (
Cont…)
5. Sharing of data and multi-user transaction
processing:

• Allowing a set of concurrent users to retrieve from and to update the


database.
• Concurrency control within the DBMS guarantees that each transaction is
correctly executed or aborted
• Recovery subsystem ensures each completed transaction has its effect
permanently recorded in the database
• OLTP (Online Transaction Processing) is a major part of database
applications. This allows hundreds of concurrent transactions to execute
per second.

18/03/25
Department of Computer Science and Business
12
systems
Disadvantages of Traditional File
system
1) Data Redundancy : Since each application has its own data file, the same data may
have to be recorded and stored in many files. For example, personal file and payroll
file, both contain data on employee name, designation etc. The result is unnecessary
duplicate or redundant data items. This redundancy requires additional or higher
storage space, costs extra time and money, and requires additional efforts to keep all
files upto-date.
2) Data Inconsistency :Data redundancy leads to data inconsistency especially when
data is to be updated. Data inconsistency occurs due to the same data items that
appear in more than one file do not get updated simultaneously in each and every file.
For example, an employee is promoted from Clerk to Superintendent and the same is
immediately updated in the payroll file may not necessarily be updated in
provident fund file. This results in two different designations of an employee at the
same time. Over the period of time, such discrepencis degrade the quality of
information contain in the data file that affects the accuracy of reports.

3/18/25
Department of Computer Science and Business
13
systems
3) Lack of Data Integration : Since independent data file exists, users face difficulty in
getting information on any adhoc query that requires accessing the data stored in
many files. In such acase complicated programs have to be developed to
retrieve data from every file or the users have to manually collect the required
information.
4) Program Dependence: The reports produced by the file processing system are
program dependent, which means if any change in the format or structure of data and
records in the file is to be made, the programs have to modified correspondingly.
Also, a new program will have to be developed to produce a new report.
5) Data Dependence :The Applications/programs in file processing system are data
dependent i.e., the file organization, its physical location and retrieval from the storage
media are dictated by the requirements of the particular application. For example, in
payroll application, the file may be organized on employee records sorted on their last
name, which implies that accessing of any employee's record has to be through the last
nameonly.

3/18/25
Department of Computer Science and Business
14
systems
6) Limited Data Sharing :There is limited data sharing possibilities
with the traditional filesystem. Each application has its own private
files and users have little choice to share the data outside their own
applications. Complex programs required to be written to obtain data
from several incompatible files.
7) Poor Data Control :There was no centralised control at the data
element level, hence a traditional file system is decentralised in
nature.

3/18/25
Department of Computer Science and Business
15
systems
Advantages of using the DBMS Approach
(Cont…)
• Controlling redundancy in data storage and in development and
maintenance efforts.
• Sharing of data among multiple users.
• Restricting unauthorized access to data.
• Providing persistent storage for program Objects
• Providing Storage Structures (e.g. indexes) for efficient Query
Processing.
• Providing backup and recovery services.
• Providing multiple interfaces to different classes of users.
• Representing complex relationships among data.
• Enforcing integrity constraints on the database.
• Drawing inferences and actions from the stored data using deductive
and active rules

18/03/25
Department of Computer Science and Business
16
systems
Historical Development of Database
Technology
Early Database Applications:

• The Hierarchical and Network Models were introduced in mid


1960s and dominated during the seventies.
• A bulk of the worldwide database processing still occurs
using these models, particularly, the hierarchical model.

Relational Model based Systems:

Relational model was originally introduced in 1970, was


heavily researched and experimented within IBM Research
and several universities.
Relational DBMS Products emerged in the early 1980s.

18/03/25
Department of Computer Science and Business
17
systems
Historical Development of Database Technology
(Cont…)
Object-oriented and emerging applications:
• Object-Oriented Database Management Systems (OODBMSs) were
introduced in late 1980s and early 1990s to cater to the need of complex
data processing in CAD and other applications.
• Many relational DBMSs have incorporated object database concepts,
leading to a new category called object-relational DBMSs (ORDBMSs)
• Extended relational systems add further capabilities (e.g. for multimedia
data, XML, and other data types)

Data on the Web and E-commerce Applications:


• Web contains data in HTML (Hypertext markup language) with links among
pages.
• This has given rise to a new set of applications and E-commerce is using
new standards like XML (eXtended Markup Language).
• Script programming languages such as PHP and JavaScript allow
generation of dynamic Web pages that are partially generated from a
database.
• Allow database updates through web pages
18/03/25
Department of Computer Science and Business
18
systems
Extending Database Capabilities

New functionality is being added to DBMSs in the following areas:

• Scientific Applications
• XML (eXtensible Markup Language)
• Image Storage and Management
• Audio and Video Data Management
• Data Warehousing and Data Mining
• Spatial Data Management
• Time Series and Historical Data Management

The above gives rise to new research and development in incorporating new
data types, complex data structures, new operations and storage and indexing
schemes in database systems.

18/03/25
Department of Computer Science and Business
19
systems
Overview of Database Languages and Architectures (
Cont…)
Data Model: is a way to organize and describe data in
database, A set of concepts to describe the structure of a
database, the operations for manipulating these structures,
and certain constraints that the database should obey.
Data Model Structure and Constraints:
• Constructs are used to define the database structure
• Constructs typically include elements (and their data
types) as well as groups of elements.
• (e.g. entity, record, table), and relationships among
such groups
• Constraints specify some restrictions on valid data,
• These constraints must be enforced at all times

18/03/25
Department of Computer Science and Business
20
systems
Overview of Database Languages and Architectures (
Cont…)
Data Model Operations:
•These operations are used for specifying
database retrievals and updates by referring to
the constructs of the data model.
•Operations on the data model may include basic
model operations
•(Ex. generic insert, delete, update) and
user-defined operations
•(Ex. compute_student_gpa, update_inventory)

18/03/25
Department of Computer Science and Business
21
systems
Categories of Data Models
Conceptual (high-level, semantic) data models:
The conceptual data model represents the overall structure of data
required to support the business requirements independent of any
software or data storage structure. . Also called entity-based or
object-based data models.

Physical (low-level, internal) data models:


Provide concepts that describe details of how data is stored in
the computer. These are usually specified in an ad-hoc manner
through DBMS design and administration manuals
Implementation (representational) data models:
Provide concepts that fall between the above two, used by many
commercial DBMS implementations (e.g. relational data models
used in many commercial systems).

18/03/25
Department of Computer Science and Business
22
systems
Schemas versus Instances
Database Schema:

The description of a database. Includes descriptions of the database structure,


data types, and the constraints on the database.

Schema Diagram:

An illustrative display of (most aspects of) a database schema.

Schema Construct:

A component of the schema or an object within the schema, e.g., STUDENT,


COURSE.

18/03/25
Department of Computer Science and Business
23
systems
Schemas versus Instances (Cont…)

Database State:
This includes the collection of all the data in the database.
Also called database instance (or occurrence or snapshot).
The term instance is also applied to individual database
components,
Ex: record instance, table instance, entity instance
The actual data stored in a database at a particular moment in
time.

18/03/25
Department of Computer Science and Business
24
systems
Database Schema vs. Database
State
Database State: Refers to the content of a database at a moment in time.

Initial Database State: Refers to the database state when it is initially


loaded into the system.

Valid State: A state that satisfies the structure and constraints of the
database.

Distinction:
• The database schema changes very infrequently.
• The database state changes every time the database is
updated .
Schema is also called intension.
State is also called extension.

18/03/25
Department of Computer Science and Business
25
systems
Schema Diagram for the database
• Student and Course Information Database

18/03/25
Department of Computer Science and Business
26
systems
Three-Schema Architecture
DBMS schemas are defined at three levels:

• Internal schema at the internal level to describe physical storage


structures and access paths (Ex: Indexes).
• Typically uses a physical data model.
• Conceptual schema at the conceptual level to describe the
structure and constraints for the whole database for a community
of users.
• Uses a conceptual or an implementation data model.
• External schemas at the external level to describe the various
user views.
• Usually uses the same data model as the conceptual schema.

18/03/25
Department of Computer Science and Business
27
systems
The Three-Schema Architecture

User Views

Structures and
Constraints

Physical Storage
Structure

Three-schema architecture

18/03/25
Department of Computer Science and Business
28
systems
The Three-Schema Architecture
(Cont..)
• Mappings among schema levels are needed to transform requests
and data.

• Programs refer to an external schema, and are mapped by the


DBMS to the internal schema for execution.

• Data extracted from the internal DBMS level is reformatted to


match the user’s external view.

• Ex: Formatting the results of an SQL query for displaying in a Web


page

18/03/25
Department of Computer Science and Business
29
systems
Data Independence
Logical Independence
Physical
Independence
Logical Data Independence: The capacity to change the
conceptual schema without having to change the external schemas
and their associated application programs.

Physical Data Independence: The capacity to change the


internal schema without having to change the conceptual schema.
For example, the internal schema may be changed when certain file
structures are reorganized, or new indexes are created to improve
database performance

18/03/25
Department of Computer Science and Business
30
systems
DBMS Languages

• A DBMS has appropriate languages and interfaces to


express database queries and updates.

• Database languages can be used to read, store and


update the data in the database.

Types of Database Language

18/03/25
Department of Computer Science and Business
31
systems
Data Definition Language (DDL)
1. Data Definition Language: DDL stands for Data Definition Language.

• It is used to define database structure or pattern.


• It is used to create schema, tables, indexes, constraints, etc. in the database.
• Using the DDL statements, you can create the skeleton of the database.
• Data definition language is used to store the information of metadata like the
number of tables and schemas, their names, indexes, columns in each
table, constraints, etc.

Here are some tasks that come under DDL:

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


• Alter: It is used to alter the structure of the database.
• Drop: It is used to delete objects from the database.
• Truncate: It is used to remove all records from a table.
• Rename: It is used to rename an object.
• Comment: It is used to comment on the data dictionary.

18/03/25
Department of Computer Science and Business
32
systems
Data Manipulation Language (DML)

DML stands for Data Manipulation Language.

• It is used for accessing and manipulating data in a database. It handles user


requests.

Here are some tasks that come under DML:

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


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

18/03/25
Department of Computer Science and Business
33
systems
Data Control Language (DCL)
DCL stands for Data Control Language.

• It is used to retrieve the stored or saved data.


• The DCL execution is transactional. It also has rollback parameters.
• (But in Oracle database, the execution of data control language does not
have the feature of rolling back.)

Here are some tasks that come under DCL:

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

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

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

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


SELECT. Department of Computer Science and Business
18/03/25 34
systems
Transaction Control Language (TCL)

TCL stands for Transaction Control Language,

• It is used to run the changes made by the DML statement.

• TCL can be grouped into a logical transaction.

Here are some tasks that come under TCL:

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

• Rollback: It is used to restore the database to original since the last


Commit.

18/03/25
Department of Computer Science and Business
35
systems
DBMS Interfaces
A database management system (DBMS) interface is a user interface
which allows for the ability to input queries to a database without
using the query language itself.

User-friendly interfaces provide by DBMS may include the following:

• Menu-Based Interfaces for Web Clients or Browsing


• Forms-Based Interfaces
• Graphical User Interface
• Natural language Interfaces

18/03/25
Department of Computer Science and Business
36
systems
DBMS Interfaces (Cont…)

1.Menu-Based Interfaces for Web Clients :

• These interfaces present the user with lists of options (called menus) that lead
the user through the formation of a request.
• Basic advantage of using menus is that they removes the tension of
remembering specific commands and syntax of any query language,
• Pull-down menus are a very popular technique in Web based interfaces.

2.Forms-Based Interfaces :

• A forms-based interface displays a form to each user.


• Users can fill out all of the form entries to insert a new data.
• This type of forms are usually designed or created and programmed
for the users that have no expertise in operating system.

18/03/25
Department of Computer Science and Business
37
systems
DBMS Interfaces (Cont…)

3.Graphical User Interface

• A GUI typically displays a schema to the user in diagrammatic form.


• The user then can specify a query by manipulating the diagram.
• In many cases, GUI’s utilize both menus and forms.
• Most GUIs use a pointing device such as mouse, to pick certain part of
the displayed schema diagram.

4.Natural language Interfaces:

• These interfaces accept request written in English or some other


language and attempt to understand them.
• A Natural language interface has its own schema, which is similar to the
database conceptual schema as well as a dictionary of important words.
• The natural language interface refers to the words in its schema as well
as to the set of standard words in a dictionary to interpret the request.

18/03/25
Department of Computer Science and Business
38
systems
Other DBMS Interfaces

•Speech as Input and Output


•Web Browser as an interface
•Parametric interfaces, e.g., bank tellers using function
keys.
•Interfaces for the DBA: (Roles of DBA)
•Creating user accounts, granting authorizations
•Setting system parameters
•Changing schemas or access paths

18/03/25
Department of Computer Science and Business
39
systems
The Component Modules of a DBMS and their
Interactions.
Users

DBA Staff
Casual Users/End users
Application
Programmers
Parametric Users

Tr
Ca sact
an
nn ion
ed
Query and Transaction
Execution

• Data Dictionary/Catalog
• Runtime Database
Processor
• Stored Database
• Concurrency
Control/Backup/Recovery
• Stored Data Manager Department of Computer Science and Business
18/03/25 40
systems
User Type Role/Responsibility

1. Database Administrator (DBA) Manage and control the entire database system.

Use the database through applications (like


2. End Users (Application Users)
websites, apps, etc.).

3. Application Programmers Develop applications that interact with the


(Developers) database.

who interact with the database using pre-defined


4. Parametric Users queries and applications but do not write their own
SQL queries.

5. Database Designers (Architects) Design database schema, tables, relationships, etc.

3/18/25
Department of Computer Science and Business
41
systems
3/18/25
Department of Computer Science and Business
42
systems
3/18/25
Department of Computer Science and Business
43
systems
3/18/25
Department of Computer Science and Business
44
systems
3/18/25
Department of Computer Science and Business
45
systems
3/18/25
Department of Computer Science and Business
46
systems
3/18/25
Department of Computer Science and Business
47
systems
Overview of Database Design Process

Back End
Front End

18/03/25
Department of Computer Science and Business
48
systems
The database design process involves six key steps:

Step No. Step Name Description


Identify business needs and
1⃣ Requirement Analysis
data requirements.
Create Entity-Relationship
Conceptual Design (ER
2⃣ (ER) Diagrams to represent
Model)
data relationships.
Convert ER Model into
Logical Design (Schema
3⃣ Relational Schema (Tables,
Design)
Attributes, Keys).
Apply Normalization Rules to
4⃣ Normalization reduce redundancy and
improve efficiency.
Optimize storage, indexing, and
5⃣ Physical Design
performance tuning.
Create the database using SQL,
6⃣ Implementation & Testing test queries, and ensure data
integrity.

3/18/25
Department of Computer Science and Business
49
systems
COMPANY Database : An Example

• We need to create a database schema design based on the


following requirements of the COMPANY Database:

•The company is organized into DEPARTMENTs.


•Each department has a name, number and an employee
who manages the department.
•We keep track of the start date of the department
manager.
•A department may have several locations.
•Each department controls a number of PROJECTs.
•Each project has a unique name, unique number and
is located at a single location.

18/03/25
Department of Computer Science and Business
50
systems
COMPANY Database : An Example
(Cont..)
•We store each EMPLOYEE’s social security number,
address, salary, sex, and birthdate.
•Each employee works for one department but may
work on several projects.
•We keep track of the number of hours per week that
an employee currently works on each project.
•We also keep track of the direct supervisor of each
employee.
•Each employee may have a number of DEPENDENTs.
•For each dependent, we keep track of their name, sex,
birthdate, and relationship to the employee.

18/03/25
Department of Computer Science and Business
51
systems
ER Diagram of a Company

18/03/25
Department of Computer Science and Business
52
systems
Entities and their Attributes are
• Employee Entity :
• Attributes of Employee Entity are Name, Id, Address, Gender, Dob
and Doj.
Id is Primary Key for Employee Entity.
• Department Entity :
• Attributes of Department Entity are D_no, Name and Location.
D_no is Primary Key for Department Entity.
• Project Entity :
• Attributes of Project Entity are P_No, Name and Location.
P_No is Primary Key for Project Entity.
• Dependent Entity :
• Attributes of Dependent Entity are D_no, Gender and relationship.

18/03/25
Department of Computer Science and Business
53
systems
Relationships are :

• Employees works in Departments


Many employee works in one Department but one employee can not work in
many departments.
• Manager controls a Department
employee works under the manager of the Department and the manager records
the date of joining of employee in the department.
• Department has many Projects
One department has many projects but one project can not come under many
departments.
• Employee works on project
One employee works on several projects and the number of hours worked by the
employee on a single project is recorded.
• Employee has dependents
Each Employee has dependents. Each dependent is dependent of only one
employee.

18/03/25
Department of Computer Science and Business
54
systems
ER Model Concepts
• Entities and Attributes
•Entities:
Entities are specific objects or things in the mini-world
that are represented in the database.
For example the EMPLOYEE John Smith, the Research
DEPARTMENT, the ProductX PROJECT
• Attributes:
Attributes are Properties used to describe an entity.
For Ex: An EMPLOYEE entity may have the attributes Name,
SSN, Address, Sex, BirthDate.
Entity will have a value for each of its attributes.
For Example: Employee entity may have
Name='John Smith', SSN='123456789', Address ='731, Fondren,
Houston, TX', Sex='M', BirthDate='09-JAN-55‘
18/03/25
Department of Computer Science and Business
55
systems
Types of Attributes
Simple Vs Composite
Single Vs Multivalued
Stored Vs Derived
• Simple Vs Composite
Simple
• Each entity has a single atomic value for the attribute.
For example, SSN or Sex.
Composite
The attribute may be composed of several components/Simple.
For example:
Address(Apt#, House#, Street, City, State, ZipCode, Country),
or Name(FirstName, MiddleName, LastName).
Composition may form a hierarchy where some
components are themselves composite.
18/03/25
Department of Computer Science and Business
56
systems
Types of Attributes (Cont…)
• In general, composite and multi-valued attributes may be nested
arbitrarily to any number of levels, although this is rare.

• For example, PreviousDegrees of a STUDENT is a composite


multi-valued attribute denoted by
• {PreviousDegrees (College, Year, Degree, Field)}

• Multiple PreviousDegrees values can exist


• Each has four subcomponent attributes:
• College, Year, Degree, Field

18/03/25
Department of Computer Science and Business
57
systems
Example of a Composite Attribute

18/03/25
Department of Computer Science and Business
58
systems
• Single Vs Multi-Valued

Single-valued: Attributes that can have single value at a


particular instance of time are called single valued
attribute.

Ex: A person can’t have more than one age value.


Therefore, age of a person is a single-values attribute.
Multi-valued: An attribute having multiple values.
For example, Color of a CAR or PreviousDegrees of a
STUDENT.
Denoted as {Color} or {PreviousDegrees}.

18/03/25
Department of Computer Science and Business
59
systems
Stored Vs Derived

Stored Attribute − Stored attributes are the attributes that


pre-exist in the physical database . For
example,Date_of_birth, Unit Price.

Derived attribute − Derived attributes are the attributes


that do not exist in the physical database, but their
values are derived from other attributes present in the
database.

For example, average_salary in a department should not


be saved directly in the database, instead it can be
derived.
18/03/25
Department of Computer Science and Business
60
systems
Entity Types and Key Attributes

Entity Type: Entities with the same basic attributes are


grouped or typed into an entity type.

For example, the entity type EMPLOYEE and PROJECT.

Key Attribute: An attribute of an entity type for which


each entity must have a unique value is called a key
attribute of the entity type.

For example, SSN of EMPLOYEE.

18/03/25
Department of Computer Science and Business
61
systems
Entity Types and Key Attributes
(Cont..)
•A key attribute may be composite.
•VehicleTagNumber is a key of the CAR entity type with
components (Number, State).

•An entity type may have more than one key.

•The CAR entity type may have two keys:


•VehicleIdentificationNumber (popularly called VIN)
•VehicleTagNumber (Number, State), aka license plate
number.
•Each key is underlined

18/03/25
Department of Computer Science and Business
62
systems
Displaying an Entity type
• In ER diagrams,
An entity type is displayed in a rectangular box

• Attributes are displayed in ovals


•Each attribute is connected to its entity type
•Components of a composite attribute are connected to
the oval representing the composite attribute
•Each key attribute is underlined
•Multivalued attributes displayed in double ovals

18/03/25
Department of Computer Science and Business
63
systems
Entity Type CAR with two keys and a corresponding Entity Set

18/03/25
Department of Computer Science and Business
64
systems
Entity Set
•Each entity type will have a collection of entities
stored in the database Called the entity set
•Three CAR entity instances in the entity set for CAR
(In Previous Slide)
•Same name (CAR) used to refer to both the entity
type and the entity set
•Entity set is the current state of the entities of that
type that are stored in the database

18/03/25
Department of Computer Science and Business
65
systems
Design of Entity Types for the COMPANY Database
Schema
• Based on the requirements, we can identify four initial entity types in the
COMPANY database:

• DEPARTMENT
• PROJECT
• EMPLOYEE
• DEPENDENT

• The initial attributes shown are derived from the requirements


description

18/03/25
Department of Computer Science and Business
66
systems
Initial Design of Entity Types:
EMPLOYEE, DEPARTMENT, PROJECT, DEPENDENT

18/03/25
Department of Computer Science and Business
67
systems
Refining the initial design by introducing
relationships
• Some aspects in the requirements will be represented as
relationships.

• ER model has three main concepts:

•Entities (and their entity types and entity sets)

•Attributes (simple, composite, multivalued)

•Relationships (and their relationship types and


relationship sets)

18/03/25
Department of Computer Science and Business
68
systems
Relationships and Relationship Types

•A relationship relates two or more distinct entities with a


specific meaning.
• For example, EMPLOYEE John Smith works on the ProductX
PROJECT, or EMPLOYEE Franklin Wong manages the Research
DEPARTMENT.

•Relationships of the same type are grouped or typed into a


relationship type.
• For example, the WORKS_ON relationship type in which
EMPLOYEEs and PROJECTs participate, or the MANAGES
relationship type in which EMPLOYEEs and DEPARTMENTs
participate.

•The degree of a relationship type is the number of


participating entity types.
• Both MANAGES and WORKS_ON are binary relationships.
18/03/25
Department of Computer Science and Business
69
systems
Relationship instances of the WORKS_FOR N:1
Relationship between EMPLOYEE and DEPARTMENT

18/03/25
Department of Computer Science and Business
70
systems
Relationship instances of the M:N WORKS_ON
Relationship between EMPLOYEE and PROJECT

18/03/25
Department of Computer Science and Business
71
systems
Relationship type vs. relationship set
• Relationship Type:
• Is the schema description of a relationship
• Identifies the relationship name and the participating entity types
• Also identifies certain relationship constraints
• Relationship Set:
• The current set of relationship instances represented in the
database
• The current state of a relationship type
Each instance in the set relates individual participating entities – one
from each participating entity type

In ER diagrams, we represent the relationship type as follows:


Diamond-shaped box is used to display a relationship
type Connected to the participating entity types via
straight lines
18/03/25
Department of Computer Science and Business
72
systems
COMPANY Database schema by introducing
relationships
•For COMPANY Database, six relationship types are
identified
•All are binary relationships (degree 2)
Listed below with their participating entity types:
• WORKS_FOR (between EMPLOYEE, DEPARTMENT)
• MANAGES (also between EMPLOYEE, DEPARTMENT)
• CONTROLS (between DEPARTMENT, PROJECT)
• WORKS_ON (between EMPLOYEE, PROJECT)
• SUPERVISION (between EMPLOYEE (as subordinate),
EMPLOYEE (as supervisor))
• DEPENDENTS_OF (between EMPLOYEE, DEPENDENT)

18/03/25
Department of Computer Science and Business
73
systems
ER DIAGRAM - RELATIONSHIPS

Relationship Types are:

• WORKS_FOR (N:1)

• MANAGES (1:1) Recursi


ve
Relation
• WORKS_ON (M:N)

• CONTROLS (1:N)

• SUPERVISION(1:N)

• DEPENDENTS_OF(1:N)

18/03/25
Department of Computer Science and Business
74
systems
Recursive Relationship
Type
•A relationship type whose with the same participating
entity type in distinct roles
•Example: the SUPERVISION relationship
EMPLOYEE participates twice in two distinct roles:
• supervisor (or boss) role
• supervisee (or subordinate) role
Each relationship instance relates two distinct EMPLOYEE
entities:
• One employee in supervisor role
• One employee in supervisee role

18/03/25
Department of Computer Science and Business
75
systems
Weak Entity Types
• An entity that does not have a key attribute
• A weak entity must participate in an identifying relationship type with
an owner entity type
• Entities are identified by the combination of:
• A partial key of the weak entity type
• The particular entity they are related to in the identifying entity
type
• For Example:
• A DEPENDENT entity is identified by the dependent’s first
name, and the specific EMPLOYEE with whom the dependent is
related
• Name of DEPENDENT is the partial key
• DEPENDENT is a weak entity type
• EMPLOYEE is its identifying entity type via the identifying
relationship type DEPENDENT_OF
Department of Computer Science and Business
18/03/25 76
systems
Constraints on
Relationships
•Constraints on Relationship Types
•(Also known as ratio constraints)
•Cardinality Ratio (specifies maximum participation)
•One-to-one (1:1)
•One-to-many (1:N) or Many-to-one (N:1)
•Many-to-many (M:N)
•Existence Dependency Constraint (specifies minimum
participation) (also called participation constraint)

18/03/25
Department of Computer Science and Business
77
systems
Many-to-one (N:1) Relationship

18/03/25
Department of Computer Science and Business
78
systems
Many-to-many (M:N)
Relationship

18/03/25
Department of Computer Science and Business
79
systems
A Recursive Relationship Supervision`

18/03/25
Department of Computer Science and Business
80
systems
Recursive Relationship Type is: SUPERVISION
(participation role names are shown)

18/03/25
Department of Computer Science and Business
81
systems
Notation for Constraints on Relationships
•Cardinality ratio (of a binary relationship): 1:1, 1:N, N:1, or
M:N
•Shown by placing appropriate numbers on the
relationship edges.
•Participation constraint (on each participating entity type):
•Total (called existence dependency) or Partial.

•Total shown by Double Line


•Partial by Single Line.

18/03/25
Department of Computer Science and Business
82
systems
Degree of Relationship
Degree of Relationship: The number of participating entities
in a relationship defines the degree of the relationship.
• Binary = Degree - 2
• Ternary = Degree - 3
• n-ary = Degree

18/03/25
Department of Computer Science and Business
83
systems
Mapping
Mapping Cardinalities:Cardinalities
Cardinality defines the number of entities in one
entity set, which can be associated with the number of entities of other
set via relationship set.

1:N
• 1:1 1:1
• 1:N
• N:1 N:1
• M:
M:N
N

18/03/25
Department of Computer Science and Business
84
systems
Notation for ER Diagrams

18/03/25
Department of Computer Science and Business
85
systems
ER Diagrams

3/18/25
Department of Computer Science and Business
86
systems
ER diagram of Bank

ER diagram of Bank has the following description :

• Bank have Customer.


• Banks are identified by a name, code, address of main office.
• Banks have branches.
• Branches are identified by a branch_no., branch_name, address.
• Customers are identified by name, cust-id, phone number, address.
• Customer can have one or more accounts.
• Accounts are identified by acc_no., acc_type, balance.
• Customer can avail loans.
• Loans are identified by loan_id, loan_type and amount.
• Account and loans are related to bank’s branch.

18/03/25
Department of Computer Science and Business
87
systems
ER Diagram of Bank

18/03/25
Department of Computer Science and Business
88
systems
Student Information System

• The student information system application will help in managing


the student’s reports, results and exams will become easier with one
such system. It will also help in saving time and effort.
• The user interface must be user friendly and easy to understand.
The authorized users will be having access to the system through
the use of login id and the password.
• The performance of the students might be in curriculum as well as
co-curriculum can also be stored through the use of this application.
The data that will be disclosed will be more secure since there will be
no access to the unknown users.

18/03/25
Department of Computer Science and Business
89
systems
Student Information System

18/03/25
Department of Computer Science and Business
90
systems
Problem Statements of Lab
Experiments
Program 1: Library Database

Consider the following schema for a Library Database:


BOOK (Bookid, Title, Publisher_Name, Pub_Year)
BOOK_AUTHORS (Book_id, Author_Name)
PUBLISHER (Name, Address, Phone)
BOOK_COPIES (Book_id, Branch_id, No-of_Copies)
BOOK_LENDING (Book_id, Branch_id, Card_No, Date_Out, Due_Date)
LIBRARY_BRANCH (Branch_id, Branch_Name, Address)

Write SQL queries to


1. Retrieve details of all books in the library – id, title, name of publisher, authors, number of
copies in each branch, etc.
2. Get the particulars of borrowers who have borrowed more than 3 books, but from Jan 2017
to Jun 2017. 3
3. Delete a book in BOOK table. Update the contents of other tables to reflect this data
manipulation operation.
4. Partition the BOOK table based on year of publication. Demonstrate its working with a
simple query.
5. Create a view of all books and its number of copies that are currently available in the
Library
18/03/25
Department of Computer Science and Business
91
systems
18/03/25
Department of Computer Science and Business
92
systems
Program 2: Order Database

Consider the following schema for Order Database:


SALESMAN(Salesman_id, Name, City, Commission)
CUSTOMER(Customer_id, Cust_Name, City, Grade, Salesman_id)
ORDERS(Ord_No, Purchase_Amt, Ord_Date, Customer_id, Salesman_id)

Write SQL queries to


1. Count the customers with grades above Bangalore’s average.
2. Find the name and numbers of all salesman who had more than one
customer.
3. List all the salesman and indicate those who have and don’t have
customers in their cities (Use UNION operation.)
4. Create a view that finds the salesman who has the customer with the
highest order of a day.
5. Demonstrate the DELETE operation by removing salesman with id
1000. All his orders must also be deleted

18/03/25
Department of Computer Science and Business
93
systems
18/03/25
Department of Computer Science and Business
94
systems
Program 3: Movie Database

Consider the schema for Movie Database:


ACTOR(Act_id, Act_Name, Act_Gender)
DIRECTOR(Dir_id, Dir_Name, Dir_Phone)
MOVIES(Mov_id, Mov_Title, Mov_Year, Mov_Lang, Dir_id)
MOVIE_CAST(Act_id, Mov_id, Role)
RATING(Mov_id, Rev_Stars)

Write SQL queries to


1. List the titles of all movies directed by ‘Hitchcock’.
2. Find the movie names where one or more actors acted in two or more
movies.
3. List all actors who acted in a movie before 2000 and also in a movie
after 2015 (use JOIN operation).
4. Find the title of movies and number of stars for each movie that has at
least One rating and find the highest number of stars that movie
received. Sort the result by movie title.
5. Update rating of all movies directed by ‘Steven Spielberg’ to 5.

18/03/25
Department of Computer Science and Business
95
systems
18/03/25
Department of Computer Science and Business
96
systems
Program 4: College Database

Consider the schema for College Database:


STUDENT(USN, SName, Address, Phone, Gender)
SEMSEC(SSID, Sem, Sec)
CLASS(USN, SSID)
SUBJECT(Subcode, Title, Sem, Credits)
IAMARKS(USN, Subcode, SSID, Test1, Test2, Test3, FinalIA)

Write SQL queries to


1. List all the student details studying in fourth semester ‘C’ section.
2. Compute the total number of male and female students in each semester and In
each section.
3. Create a view of Test1 marks of student USN ‘1BI15CS101’ in all subjects.
4. Calculate the FinalIA (average of best two test marks) and update the corresponding
table for all students.
5. Categorize students based on the following criterion: If FinalIA = 17 to 20 then CAT
= ‘Outstanding’ If FinalIA = 12 to 16 then CAT = ‘Average’ If FinalIA< 12 then CAT =
‘Weak’ Give these details only for 8th semester A, B, and C section students

18/03/25
Department of Computer Science and Business
97
systems
18/03/25
Department of Computer Science and Business
98
systems
Program 5: Company Database

Consider the schema for Company Database:


EMPLOYEE(SSN, Name, Address, Sex, Salary, SuperSSN, DNo)
DEPARTMENT(DNo, DName, MgrSSN, MgrStartDate)
DLOCATION(DNo,DLoc)
PROJECT(PNo, PName, PLocation, DNo)
WORKS_ON(SSN, PNo, Hours)
Dependenta(SSN,Name,Sex,Birthdate,Relationship)
Write the following
1. Schema diagram and ER Diagram
2. Degree of Relaitonship type
3. Recursive Relationship
4. Cardinality ration
5. Participation
6. Weak Entity Type

18/03/25
Department of Computer Science and Business
99
systems
18/03/25
Department of Computer Science and Business
100
systems
Differences between DBMS and File System
DBMS File System
DBMS is a collection of data. In DBMS, the File system is a collection of data. In this
user is not required to write the procedures. system, the user has to write the procedures
for managing the database.
DBMS gives an abstract view of data that File system provides the detail of the data
hides the details. representation and storage of data.
DBMS provides a crash recovery mechanism, File system doesn't have a crash mechanism,
i.e., DBMS protects the user from the system i.e., if the system crashes while entering some
failure. data, then the content of the file will lost.
DBMS provides a good protection mechanism. It is very difficult to protect a file under the file
system.
DBMS contains a wide variety of sophisticated File system can't efficiently store and retrieve
techniques to store and retrieve the data. the data.
DBMS takes care of Concurrent access of In the File system, concurrent access has
data using some form of locking. many problems like redirecting the file while
other deleting some information or updating
some information.

18/03/25
Department of Computer Science and Business
101
systems
Generalization and
Specialization
Generalization is the process of
extracting common properties from a set
of entities and create a generalized entity
from it. It is a bottom-up approach in
which two or more entities can be
generalized to a higher level entity if they
have some attributes in common.

For Example: STUDENT and FACULTY


can be generalized to a higher level entity
called PERSON as shown in Diagram.

In this case, common attributes like


P_NAME, P_ADD become part of higher
entity (PERSON) and specialized
attributes like S_FEE become part of
specialized entity (STUDENT).

18/03/25
Department of Computer Science and Business
102
systems
Generalization and Specialization
(Cont…)
Specialization, an entity is divided into
sub-entities based on their
characteristics. It is a top-down
approach where higher level entity is
specialized into two or more lower level
entities.

For Example, EMPLOYEE entity in an


Employee management system can be
specialized into DEVELOPER, TESTER
etc. as shown in Diagram.

In this case, common attributes like


E_NAME, E_SAL etc. become part of
higher entity (EMPLOYEE) and
specialized attributes like TES_TYPE
become part of specialized entity
(TESTER).
18/03/25
Department of Computer Science and Business
103
systems
Important Questions asked in VTU Semester End Exam ( SEE)

Dec.2019/Jan.2020

18/03/25
Department of Computer Science and Business
104
systems
18/03/25
Department of Computer Science and Business
105
systems
18/03/25
Department of Computer Science and Business
106
systems
ER Diagram Examples
✔ Library Management System ✔ Employee Database
✔ Hospital Management ✔ E-Farming Management System
✔ Student Database ✔ Leave Management System
✔ College Database ✔ Tourism Management system
✔ online Shopping ✔ Transport Management System
✔ Bank Databas ✔ Time Table Management
✔ Company Database ✔ Taxi Management System
✔ Blood Donation ✔ Travel agency Management
✔ Railway Reservation system
✔ Real estate Management ✔ Toll Gate Management System
System ✔ University Management System
✔ Restaurant Management System ✔ Inventory Management
✔ Recruitment Management ✔ Invoice Management System
system ✔ Insurance Management System
✔ Quiz Application ✔ Online Food Ordering System
✔ Question Paper Generator ✔ Online Book Store
✔ Website development ✔ Online Voting System
✔ Waste Management system ✔ Payroll Management System
✔ Weather forecasting system ✔ Pharmacy Management System
✔ Wholesale Management
18/03/25
Department of Computer Science and Business
107
systems
3/18/25
Department of Computer Science and Business
108
systems

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy