Professional Documents
Culture Documents
Sidak Preet Ism File Bba G 4
Sidak Preet Ism File Bba G 4
OF
“INFORMATION SYSTEM MANAGEMENT LAB”
B.B.A. (G) 212
Submitted in partial fulfillment of the
requirement Of
B.B.A. (G)
Batch 2021-2022
2
Q1. INTRODUCTION TO DATABASE?
DBMS stands for DataBase Management System. Its file extension is (.dbf). Database is a
collection of data and management system which is a set of programs to store and retrieve
those data. It is general purpose software that enables users to define, create and maintain a
database. It facilitates the processes of defining, constructing, manipulating databases for
various applications. It also helps in sharing, protection and maintenance of databases.
Database stores information whereas DBMS is a system to manage database.
It is any collection of data that is stored as a file or a set of files or magnetic disc or some
secondary devices. The information in the file may be broken down into records. Each record
consists of one or more fields. We perform different types of command in a database to
retrieve or create report on particular data.
It is a collection of interrelated data. These can be stored in the form of tables. A database can
be of any size and varying complexity. A database may be generated and manipulated
manually or it may be computerized.
A Dictionary, a phone book, a collection of recipes and a TV guide are examples of non
computerized databases. The examples of computerized databases includes customer files,
employee rosters, books catalog, equipment inventories and sales transactions. Typically, a
database manager provides users the capabilities of controlling read/write access, specifying
report generation, and analyzing usage.
3
⮚ DATA BASE MANAGEMENT SYSTEM
4
⮚ NEED FOR DBMS
Database systems are basically developed for large amount of data. A database management
system (DBMS) can help address the employee count scenario and a range of even more
complex situations related to cost, order status or inventory management by presenting the same
data to everyone in the business at the same time. A DBMS also eliminates the frustrating hunt
for the right version of the right spreadsheet on a vast and disorganized network drive. When
dealing with huge amount of data, there are two things that require optimization:
∙ Storage of data
∙ Retreival of data
Storage: The data is stored in such a way that it acquires less space as the redundant data
(duplicate data) has been removed before storage.
Retreival: Along with storing the data in an optimized and systematic manner, it is also
important that retrieve the data quickly when needed.
A Data Base Management System is a system software for easy, efficient and reliable data
processing and management. It can be used for:
∙ Creation of a database.
∙ Retrieval of information from the database.
∙ Updating the database.
∙ Managing a database.
Needs are:
∙ As businesses expand, more sophisticated tools are needed to manage data. Tools that serve
start-ups well are overwhelmed by the demands faced by larger businesses. ∙ A database
management system (DBMS) is a powerful tool used to store data, secure it, protect it and
make it quickly available to people who need it.
5
USES OF DBMS:
6
CHARACTERISTICS OF DBMS:
1. Real World Entity
DBMS these days is very realistic and real-world entities are used to design its architecture. Also
behavior and attributes are used by DBMS. To simplify it we can take an example of an organization
database where employee is an entity and his employee id is an attribute.
2. Self-Describing Nature
Before DBMS, traditional file management system was used for storing information and data. There was
no concept of definition in traditional file management system like we have in DBMS. A DBMS should
be of Self- Describing nature as it not only contains the database itself but also the metadata. A metadata
(data about data) defines and describes not only the extent, type, structure and format of all data but also
relationship between data. This data represent itself that what actions should be taken on it.
3. Support ACID Properties
Any DBMS is able to support ACID (Accuracy, Completeness, Isolation, and Durability) properties. It is
made sure in every DBMS that the real purpose of data should not be lost while performing transactions
7
like delete, insert and update. Let us take an example; if an employee name is updated then it should
make sure that there is no duplicate data and no mismatch of employee information.
4. Concurrent Use of Database
There are many chances that many users will be accessing the data at the same time. They may require
altering the database system concurrently. At that time, DBMS supports them to concurrently use
database without any problem. With the help of concurrency, economy of the system can be increased.
For Example, employees of railway reservation system can book and access tickets for passengers
concurrently. Every employee can see on his own interface that how many seats are available or bogie is
fully booked.
Program-data independence provides a big relief to database users. In traditional file management
system, structure of data files was defined in the application programs so user had to change all the
programs that are using that particular data file.
But in DBMS, structure of data files is not stored in the program but it is stored in system catalogue.
With the help of this, internal improvement of data efficiency or any changes in the data do not have any
effect on application software.
6. Transactions
Transactions are bunch of actions that are done to bring database from one consistent state to new
consistent state. Traditional file-based system did not have this feature. Transaction is always atomic that
means it can never be further divided. It can only be completed or uncompleted.
For example, A person wants to credit money from his account to another person’s account. Then
transaction will be complete if he sends money and other guy receives his money. Anything other than
this can lead to an inconsistent transaction.
8
PROPERTIES OF DBMS:
⮚ ACID Properties
A transaction is a very small unit of a program and it may contain several low level tasks. A transaction
in a database system must maintain Atomicity, Consistency, Isolation, and Durability − commonly
known as ACID properties − in order to ensure accuracy, completeness, and data integrity.
Atomicity
This property states that a transaction must be treated as an atomic unit, that is, either all of its operations
are executed or none. There must be no state in a database where a transaction is left partially completed.
States should be defined either before the execution of the transaction or after the execution/ failure of the
transaction.
Consistency
The database must remain in a consistent state after any transaction. No transaction should have any
adverse effect on the data residing in the database. If the database was in a consistent state before the
execution of a transaction, it must remain consistent after the execution of the transaction as well.
Isolation
In a database system where more than one transaction are being executed simultaneously and in parallel,
the property of isolation states that all the transactions will be carried out and executed as if it is the only
transaction in the system. No transaction will affect the existence of any other transaction.
Durability
The database should be durable enough to hold all its latest updates even if the system fails or restarts. If
a transaction updates a chunk of data in a database and commits, then the database will hold the modified
data. If a transaction commits but the system fails before the data could be written on to the disk, then
that data will be updated once the system springs back into action.
9
⮚ Advantage of Database Management System (DBMS):
∙ Better Data Transferring:
Database management creates a place where users have an advantage of more and better managed
data. Thus making it possible for end-users to have a quick look and to respond fast to any
changes made in their environment.
10
Q2. Make ER Diagram of Hospital Management System
⮚ SYSTEM ENTITY RELATIONSHIP MODEL
An Entity–relationship model (ER model) describes the structure of a database with the
help of a diagram, which is known as Entity Relationship Diagram (ER Diagram). An ER
model is a design or blueprint of a database that can later be implemented as a database. The
main components of E-R model are: entity set and relationship set. An entity–relationship
model (or ER model) describes interrelated things of interest in a specific domain of
knowledge. A
basic ER model is composed of entity types(which classify the things of interest) and
specifies relationships that can exist between entities (instances of those entity types).
It is a high-level data model. This model is used to define the data elements and relationship
for a specified system. It develops a conceptual design for the database. It also develops a
very simple and easy to design view of data.
An ER diagram shows the relationship among entity sets. An entity set is a group of similar
entities and these entities can have attributes. In terms of DBMS, an entity is a table or
attribute of a table in database,so by showing relationship among tables and their attributes,
ER diagram shows the complete logical structure of a database. ER diagram (Entity
relationship diagram) displays the relationships of entity set stored in a database. In other
words, we can say thatER diagrams help you to explain the logical structure of databases.
ER diagrams often use symbols to represent three different types of information. Boxes are
commonly used to represent entities. Diamonds are normally used to represent relationships
and ovals are used to represent attributes of and entity.
11
⮚ Components of a ER Diagram
1. Entity
Entity can be described as the atomic real world item. It may be person, place, object, event
etc. An entity is an object or component of data. For example. If all the students studying in a
college such group is called entity set. An entity is represented as rectangle in an ER
diagram.
Entity
2. Attribute
An attribute describes the property of an entity. An entity is described using a set of
attributes. An attribute is represented as Oval in an ER diagram.
12
3. Relationships
Association among two or more entities is called relationship. A relationship is defined
as the bond attachment between two or more entities normally a verb in a sentence
signifies a relationship. The graphical representation of a relationship is a Diamond.
13
ER DIAGRAM OF HOSPITAL MANAGEMENT SYSTEM:
Step 1: E-R Diagram
This ER Diagram represents the model of Hospital Management System Entity. It shows all
the visual instrument of database tables and the relations between patient, employee, record,
doctor and room etc. It used structure data and to define the relationships between structured
data groups of Hospital Management System functionalities. The entities and attributes are:-
14
∙ Patients Entity: Attributes of patients are p_id, p_name, p_address, p_gender
and p_contact_no.
∙ Room Entity: Attributes are room_type, room_id and room_period.
∙ Employee Entity: Attributes of employees are e_id, e_salary, e_address,
e_gender, e_name and e_contact_no.
∙ Medicine Entity: Attributes of medicines are med_price, med_quantity and med_code.
An Entity–relationship model (ER model) describes the structure of a database with the
help of a diagram, which is known as Entity Relationship Diagram (ER Diagram). An ER
model is a design or blueprint of a database that can later be implemented as a database. The
main components of E-R model are: entity set and relationship set. An entity–relationship
model (or ER model) describes interrelated things of interest in a specific domain of
knowledge. A
basic ER model is composed of entity types(which classify the things of interest) and
specifies relationships that can exist between entities (instances of those entity types).
It is a high-level data model. This model is used to define the data elements and relationship
for a specified system. It develops a conceptual design for the database. It also develops a
very simple and easy to design view of data.
An ER diagram shows the relationship among entity sets. An entity set is a group of similar
entities and these entities can have attributes. In terms of DBMS, an entity is a table or
attribute of a table in database,so by showing relationship among tables and their attributes,
ER diagram shows the complete logical structure of a database. ER diagram (Entity
relationship diagram)
15
displays the relationships of entity set stored in a database. In other words, we can say thatER
diagrams help you to explain the logical structure of databases.
ER diagrams often use symbols to represent three different types of information. Boxes are
commonly used to represent entities. Diamonds are normally used to represent relationships
and ovals are used to represent attributes of and entity.
Components of a ER Diagram
An ER diagram has three main components:
1.Entity
2.Attribute
3. Relationship
1. Entity
Entity can be described as the atomic real world item. It may be person, place, object, event etc. An
entity is an object or component of data. For example. If all the students studying in a college such
group is called entity set. An entity is represented as rectangle in an ER diagram.
Entity
2. Attribute
An attribute describes the property of an entity. An entity is described using a set of
attributes. An attribute is represented as Oval in an ER diagram.
3. Relationships:-
Association among two or more entities is called relationship. A relationship is defined as
the bond attachment between two or more entities normally a verb in a sentence signifies a
relationship. The graphical representation of a relationship is a Diamond.
16
ER DIAGRAM OF HOTEL MANAGEMENT SYSTEM:
∙
Hotel entity : attributes of hotel are hotel_id, hotel_name,hotel_rent.
17
∙ Room Entity: Attributes of room_type, room_id and room_period.
Syntax: create table table_name(column1 data type primary key, column2 data type, column3
data type,.columnN data type);
QUERY:
For creating student table the following command is: create table students(id
integar(5),name varchar(20), age integer(3), class varchar(5), address varchar(20)
OUTPUT:
You can verify if your table has been created successfully by looking at the message
displayed by the SQL server, otherwise you can use DESC command as mentioned
above.
18
Primary key is a field in a table which uniquely identifies each row/record in database
table. It should contain any NULL values.
QUERY:
For inserting values in student table the following command is
OUTPUT:
19
Q5. Create an emp_info and insert values in it.
Ans 5: Creating a basic table involves naming the table and defining its columns and
each column’s data type.
Syntax: create table table_name(column1 data type primary key, column2 data
type, column3 data type,. columnN data type);
QUERY:
For creating student table the following command is: create table emp_info( emp_id
integer(20) primary key, emp_name varchar(20)not null, emp_city varchar(20)not null,
emp_salary number(30)not null, emp_dept varchar(20) not null);
OUTPUT:
You can verify if your table has been created successfully by looking at the message
displayed by the SQL server,
20
Primary key is a field in a table which uniquely identifies each row/record in
database table. It should contain any NULL values.
QUERY:
values
(1,'Raghav','Delhi',40000,'Human Resources');
values
(2,'Veenu','Mumbai',50000,'Finance');
values
(3,'Alok','Bangalore',35000,'Purchase');
values
(4,'Neena','Jaipur',72000,'Marketing');
values
(5,'Karina','Chennai',60000,'Sales');
21
OUTPUT:
22
The table will execute with the fields you have entered.
QUERY: Select emp_salary from emp_info;
values
(1,'Raghav','Delhi',40000,'Human Resources');
values
(2,'Veenu','Mumbai',50000,'Finance');
values
(3,'Alok','Bangalore',35000,'Purchase');
23
Insert into emp_info(emp_id,emp_name,emp_city,emp_salary,emp_dept) values
(4,'Neena','Jaipur',72000,'Marketing');
(5,'Karina','Chennai',60000,'Sales');
OUTPUT:
24
Q7. Display the different departments in the company from
Emp_info table.
Ans 7 :First we have to display the table where all the records are entered for the
following command is: - select * from Emp_info;
The table will execute with the fields you have entered.
QUERY: Select emp_dept from emp_info;
Insert into emp_info(emp_id,emp_name,emp_city,emp_salary,emp_dept)
values
(1,'Raghav','Delhi',40000,'Human Resources');
values
(2,'Veenu','Mumbai',50000,'Finance');
25
values
(3,'Alok','Bangalore',35000,'Purchase');
(4,'Neena','Jaipur',72000,'Marketing');
OUTPUT:
26
Q8. Display total number of departments in the company
from emp_info table.
Ans 8: First we have to display the table where all the records are entered for the
following command is: - select * from Emp_info;
The table will execute with the fields you have entered.
Here we will use an aggregate function: - COUNT() It returns the number of rows
in a table. It allows you to count all rows or only rows that match a specified
condition.
27
Insert into emp_info(emp_id,emp_name,emp_city,emp_salary,emp_dept)
values
(1,'Raghav','Delhi',40000,'Human Resources');
values
(2,'Veenu','Mumbai',50000,'Finance');
values
(3,'Alok','Bangalore',35000,'Purchase');
values
(4,'Neena','Jaipur',72000,'Marketing');
values
(5,'Karina','Chennai',60000,'Sales');
28
OUTPUT:
Q9. Display the name of employees whose name starts with ‘A’.
Ans 9: Under this Like operator is used to search for a specified pattern in a column.
There are 2 wildcards often used in conjunction with the Like operator: %, _
We have also used Where clause in this command. Where clause allows you to
specify a search condition for the rows returned by a query. Where clause in select
statement is to filter rows from the result set.
29
Syntax: Select column1,coulmn2,from table_name where condition;
values
(1,'Raghav','Delhi',40000,'Human Resources');
values
(2,'Veenu','Mumbai',50000,'Finance');
values
(3,'Alok','Bangalore',35000,'Purchase');
30
values
(4,'Neena','Jaipur',72000,'Marketing');
values
(5,'Karina','Chennai',60000,'Sales');
OUTPUT:
31
Q10. Display the name of those employees whose 2nd alphabet is ‘a’
ANS 10. Under this Like operator is used to search for a specified pattern in a
column. There are 2 wildcards often used in conjunction with the Like operator:
%, _
values
(1,'Raghav','Delhi',40000,'Human Resources');
values
(2,'Veenu','Mumbai',50000,'Finance');
values
(3,'Alok','Bangalore',90000,'Purchase');
values
32
(4,'Neena','Jaipur',72000,'Marketing');
values
(5,'Karina','Chennai',60000,'Sales');
OUTPUT:
33
Here the output will show the name of only those employees whose 2nd alphabet is
‘A’. Where we have used both wildcards: %, _
values
(1,'Raghav','Delhi',40000,'Human Resources');
values
(2,'Veenu','Mumbai',50000,'Finance');
values
(3,'Alok','Bangalore',90000,'Purchase');
values
(4,'Neena','Jaipur',72000,'Marketing');
values
(5,'Karina','Chennai',60000,'Sales');
34
Output:
35
It will display the id and name of those employees who live in Delhi only.
values
(1,'Raghav','Delhi',40000,'Human Resources');
values
(2,'Veenu','Mumbai',50000,'Finance');
values
(3,'Alok','Bangalore',90000,'Purchase');
values
(4,'Neena','Jaipur',72000,'Marketing');
36
Insert into emp_info(emp_id,emp_name,emp_city,emp_salary,emp_dept)
values
(5,'Karina','Chennai',60000,'Sales');
37
Output:
It will display the id and name of those employees who lives in Delhi or Mumbai.
Q13. Display name & max salary in each department of company.
ANS 13. Under this Where clause allows you to specify a search condition for the rows
returned by a query. Where clause in select statement is to filter rows from the result
set.
Apart from that MAX() function is also used. It is an aggregate function that returns
38
In this query there are 2 statements made together where we have used where clause
and max function. This is an example of Nested querywhere there are 2 queries:
Inner and Outer.
Outer Query.
Inner Query.
Now, inner query will be executed first and will return the output i.e. it will display
the maximum salary from emp_info table which is 90000. And then it will be
compared with the outer query which is: select the emp_name and emp_dept.
Insert into emp_info(emp_id,emp_name,emp_city,emp_salary,emp_dept)
values
(1,'Raghav','Delhi',40000,'Human Resources');
values
(2,'Veenu','Mumbai',50000,'Finance');
values
(3,'Alok','Bangalore',90000,'Purchase');
values
39
(4,'Neena','Jaipur',72000,'Marketing');
values
(5,'Karina','Chennai',60000,'Sales');
Output:
40
Q14. Add Phone No. Column in emp_info table.
ANS 14. Here ALTER command is used. It helps to modify an existing database and
table. The ALTER statement is used to “ADD”, “DROP” and “MODIFY” the existing
table.
Syntax (to add a column): ALTER table table_name ADD column_name, datatype;
values
(1,'Raghav','Delhi',40000,'Human Resources');
41
values
(2,'Veenu','Mumbai',50000,'Finance');
(3,'Alok','Bangalore',90000,'Purchase');
(4,'Neena','Jaipur',72000,'Marketing');
(5,'Karina','Chennai',60000,'Sales');
42
Output:
Q15. Update the city of Mr. John from Jaipur to Chennai.
ANS 15. Here UPDATE statement is used. It helps to modify existing data in a table.
Update statement change values in one or more columns of a single row or multiple
rows.
Syntax: UPDATE table_name set column1= value where some_column= some_value.
QUERY: Update emp_info set emp_city= “Chennai” where emp_name= “alok”; Insert
into emp_info(emp_id,emp_name,emp_city,emp_salary,emp_dept)
values
(1,'Raghav','Delhi',40000,'Human Resources');
values
(2,'Veenu','Mumbai',50000,'Finance');
43
values
(3,'Alok','Bangalore',90000,'Purchase');
Insert into emp_info(emp_id,emp_name,emp_city,emp_salary,emp_dept) values
(4,'Neena','Jaipur',72000,'Marketing');
(5,'Karina','Chennai',60000,'Sales');
44
Output:
45