You are on page 1of 30

1

PRACTICAL FILE OF

DATABASE MANAGEMENT SYSTEM

BACHELOR OF BUSINESS ADMINISTRATION (2019-2022)

MERI COLLEGE OF ENGINEERING AND TECHNOLOGY, (SAMPLA)

MERI
COLLEGE

SUBMITTED TO - SUBMITTED BY –

Ms. SHEETAL MAM AMAN

(ASSISTANT PROFESSOR) BBA 4 th Semester

SECTION - B
2

INDEX
Seria PAGE N0. Practical Topic Sign.
l No.
1. 3–5 To Study Advantages and
Disadvantages of DBMS
2. 6–9 Introduction to MS Access

3. 9 – 19 Introduction to SQL

4. 20 – 26 CREATE VARIOUS TABLES


USING CREATE COMMAND AND
INSERT VALUES USING
INSERT COMMAND
5. 27 - 30 TO PERFORM UPDATION AND
DELETION USING UPDATE AND
DELETE COMMAND
3

PRACTICAL-1

AIM: - To study advantages and disadvantages of “DBMS”.

DATABASE MANAGEMENT SYSTEM (DBMS):

A database management system is a software that enables users to interact with the database. It
enables users to store, modify and extract information from a database as per the requirements.

It is an intermediate layer between user programs and the data. User programs access the DBMS which
then accesses the data. It controls the creation, maintenance and utilization of the databases of an
organisation.

Thus, a DBMS is a collection of a database which acts as a single centralized databank for the various
data processing applications and programs for management of the database.

A DBMS has many uses:

1. It enables users to access and manipulates the database.


2. It provides a building block in constructing data processing systems for applications requiring
database access- MIS or systems for accounting, production and inventory control or customer
support.
3. It helps the DBA to perform certain managerial duties.

Advantage of DBMS:

1. Improved data sharing:

 The DBMS helps create an environment in which end users have better access to more and better-
managed data.
 Such access makes it possible for end users to respond quickly to changes in their envir onment.

2. Improved data security:

 The more users access the data, the greater the risks of data security breaches. Corporations
invest considerable amounts of time, effort, and money to ensure that corporate data are used
properly.
 A DBMS provides a framework for better enforcement of data privacy and security policies.
4

3. Better data integration:

 Wider access to well-managed data promotes an integrated view of the organization’s operations
and a clearer view of the big picture.
 It becomes much easier to see how actions in one segment of the company affect other
segments.

4. Minimized data inconsistency:

 Data inconsistency exists when different versions of the same data appear in different places.
 For example, data inconsistency exists when a company’s sales department stores a sales
representative’s name as “Bill Brown” and the company’s personnel department stores that same
person’s name as “William G. Brown,” or when the company’s regional sales office shows the
price of a product as $45.95 and its national sales office shows the same product’s price as
$43.95.
 The probability of data inconsistency is greatly reduced in a properly designed database.

5. Improved data access:

 The DBMS makes it possible to produce quick answers to ad hoc queries.


 From a database perspective, a query is a specific request issued to the DBMS for data
manipulation—for example, to read or update the data. Simply put, a query is a question, and an
ad hoc query is a spur-of-the-moment question.
 The DBMS sends back an answer (called the query result set) to the application.
 For example, end users

6. Improved decision making:

 Better-managed data and improved data access make it possible to generate better-quality
information, on which better decisions are based.
 The quality of the information generated depends on the quality of the underlying data.
 Data quality is a comprehensive approach to promoting the accuracy, validity, and timeliness of
the data. While the DBMS does not guarantee data quality, it provides a framework to facilitate
data quality initiatives.
 Increased end-user productivity
 The availability of data, combined with the tools that transform data into usable information,
empowers end users to make quick, informed decisions that can make the difference between
success and failure in the global economy.

Disadvantage of DBMS:

1. Increased costs:

 Database systems require sophisticated hardware and software and highly skilled personnel.
 The cost of maintaining the hardware, software, and personnel required to operate and manage a
database system can be substantial. Training, licensing, and regulation compliance costs are
often overlooked when database systems are implemented.
5

2. Management complexity:

 Database systems interface with many different technologies and have a significant impact on a
company’s resources and culture.
 The changes introduced by the adoption of a database system must be properly managed to
ensure that they help advance the company’s objectives. Given the fact that database systems
hold crucial company data that are accessed from multiple sources, security issues must be
assessed constantly.

3. Maintaining currency:

 To maximize the efficiency of the database system, you must keep your system current.
 Therefore, you must perform frequent updates and apply the latest patches and security
measures to all components.
 Because database technology advances rapidly, personnel training costs tend to be significant.
Vendor dependence.
 Given the heavy investment in technology and personnel training, companies might be reluctant
to change database vendors.

4. Frequent upgrade/replacement cycles:

 DBMS vendors frequently upgrade their products by adding new functionality. Such new features
often come bundled in new upgrade versions of the software.
 Some of these versions require hardware upgrades. Not only do the upgrades themselves cost
money, but it also costs money to train database users and administrators to properly use and
manage the new features.
6

PRACTICAL-2

AIM: - Introduction to MS Access.

What is MS Access?

Microsoft Access is a database management system (DBMS) that combines the relational
Microsoft Jet Database Engine with a graphical user interface and software-development tools.

Home Page of MS Access:

What are the uses of MS Access?


MS Access can be used to develop application software and is generally used by data
architects, software developers and power users. Following are the major uses of MS Access:

 Manage accounts and bills


7

 Store data in the form of tables and edit or customise them later as per the requirement of
the user
 It can be used to make our websites
 Comparing data or finding a relationship between the existing data can be done using Access

What are the major components of MS Access?


The major components of MS Access are as follows:

 Tables
 Queries
 Relationships
 Macros
 Forms
 Reports

How many types of databases are there in MS Access?


There are two types of database in MS Access:

 Flat File Database: When the data is stored in the form of a plain text file and cannot
incorporate multiple tables. 
 Relational Database: When the data is stored in a form that the data items are related to
one another. It supports multiple tables which organise the text in rows and columns.

Components of MS Access:

The main usage of MS Access is for accounting. Since it is Microsoft’s primary accounting
database, it can be used to manage invoice/bills, manage accounts, keep an eye on credit and
debit, etc. 

When we create a document of Access, data can be stored and accessed easily through multiple
components. There are seven major components of MS Access database. Discuss below are the
same in brief:

 Tables: A table in Access is similar to any other tabulated data in the form of rows and
columns. However, when adding data to a program to create a table, all the information
entered must be correct as if any incorrect data is entered the processing may become
slow or may not give the correct answer. The appearance of the table may look similar to
the one formed in Excel with column heading and titles.

 Queries: Once a table is created and the user or programmer is looking for a calculated
output, then it is called queries. This may include filtering, calculating, sorting, updating,
etc.
8

 Relationships: As the name suggests, when more than one table is added, the relation or
connection between them can be achieved. There three ways in which the connection
between the tables can be determined:

1. One to one
2. One to Many
3. Many to Many

 Macros: The tool using which predefined actions which can automate tasks on an Access
report is called macros. Multiple tasks can be assigned and they will function whenever the
macros option is selected on a report

 Forms: A user interface for a database application can be created using forms. Forms can
further be divided into two: bound and unbound forms

 Report: Once all the information is entered into the database, it can be reviewed or
analysed using a report. A report can then be customised or modified as per the user’s
requirement

 Module: This allows a set of pre-defined instructions to be created by a programmer in


the database. They can be used throughout the database

Benefits and Limitations of using MS Access:


It was Microsoft’s first database software, and came along with a lot of advantages and
convenience for its users. At the same time, there were limitations to it. Discussed below are the
benefits and limitations which came along with MS Access usage.

Benefits:

 Easy to create database within lesser time duration


 Used a very comprehensive programming language which made it user friendly
 With each revised version, new options and features were made available to the users for
their convenience
 It is easy to install and then easy to understand its working
 Importing data was easy
 Graphical user interface made it easy to use

Limitations:
9

 Not too many people can use the same database at a single time. This may affect its
speed and efficiency
 The same database was tough to use with different Operating systems
 Better database systems can be used for confidential data

PRACTICAL –3

AIM:- To study about SQL

STRUCTURED QUERY LANGUAGE (SQL):

SQL stands for Structured Query Language and it is an ANSI standard computer language for
accessing and manipulating database systems. It is used for managing data in relational
database management system which stores data in the form of tables and relationship
between data is also stored in the form of tables. SQL statements are used to retrieve and
update data in a database.

TYPES OF STRUCTURED QUERY LANGUAGE:


10

i. DDL: Data definition language helps you to define the database structure or schema.
Let’s learn about DDL commands with syntax. Four types of DDL commands in SQL are –
create, drop, alter and truncate.
ii. DML: Data Manipulation Language (DML) allows you to modify the database instance by
inserting, modifying, and deleting its data. It is responsible for performing all types of
data modification in a database.
iii. DCL: data control language includes commands like GRANT and REVOKE, which are
useful to give “rights & permissions”. Other permissions control parameters of the
database system. Commands that come under TCL.
iv. TCL: transaction control language or TCL commands deal with the transaction within the
database. There are three commands that come under TCL- commit, rollback, and save
point
v. DQL: Data query language is used to fetch the data from the database. It uses only one
command- select.

FEATURES OF SQL:

 Data Definition language (DDL): It contains of commands which defines the data
 Data Manipulation Language (DML): Data Manipulation Language contains
commands used to manipulate the data.
 Triggers: Triggers are actions performed when certain conditions are met on the data. A
trigger contains of three parts:
 Event – The change in the database that activates the trigger is event.
 Condition – A query or test that is run when the trigger is activated.
 Action – A procedure that is executed when trigger is activated and the condition
met is true.
11

 Client server execution and remote database access: Client server technology
maintains a many to one relationship of clients (many) and server (one). We have
commands in SQL that control how a client application can access the database over a
network.

 Security and authentication: SQL provides a mechanism to control the database


meaning it makes sure that only the particular details of the database is to be shown
the user and the original database is secured by DBMS.

 Embedded SQL: SQL provides the feature of embedding host languages such as C,
COBOL, and Java for query from their language at runtime.

 Transaction Control Language:


Transactions are an important element of DBMS and to control the transactions, TCL is
used which has commands like commit, rollback and save point.

Advantages of SQL :

SQL has many advantages which makes it popular and highly demanded. It is a
reliable and efficient language used for communicating with the database. Some
advantages of SQL are as follows:

 Faster Query Processing – Large amount of data is retrieved quickly and efficiently.
Operations like Insertion, deletion, manipulation of data is also done in almost no time.

 No Coding Skills –For data retrieval, large number of lines of code is not required. All
basic keywords such as SELECT, INSERT INTO, UPDATE, etc are used and also the
syntactical rules are not complex in SQL, which makes it a user-friendly language.

 Standardized Language – Due to documentation and long establishment over years, it


provides a uniform platform worldwide to all its users.

 Portable – It can be used in programs in PCs, server, laptops independent of any


platform (Operating System, etc). Also, it can be embedded with other applications as
per need/requirement/use.

 Interactive Language – Easy to learn and understand, answers to complex queries can
be received in seconds.

Disadvantages of SQL :
12

Although SQL has many advantages, still there are a few disadvantages. Various
Disadvantages of SQL are as follows:

 Complex Interface – SQL has a difficult interface that makes few users uncomfortable
while dealing with the database.
 Cost – Some versions are costly and hence, programmers cannot access it.
 Partial Control – Due to hidden business rules, complete control is not given to the
database.

SQL Commands:

 SQL commands are instructions. It is used to communicate with the database. It is also
used to perform specific tasks, and specific data.

 SQL can perform various tasks like create a table, add data to tables, drop the table ,
modify the table , set permission for users.

CREATE TABLE COMMAND

Aim: Create various tables with the command “create table” .


FOR COLUMN LEVEL:
SYNTEX:

Create table <table_name> (<field_name1> field_type Constraint_name);


FOR TABLE LEVEL:
SYNTEX:

Create table
<table_name>
(<field_name1>field1_ty
pe
<field_name2>field2_type

<field_namen>fieldn_type
Constraint (field_names)
13

);
EXAMPLE:
14

%Atocommi Dispay 10 •
describe student;

Results Explain Describe Saved SQL History

Object Type TABLE Object STUDENT

Tab Ie C o I umn Data Typ e Len gth P re c i s i on S c at e P ary K ey Nu II ab Ie D


-§! i| Eh›"I rL!LL U' Number rim efa
1
'4fi.MF Varchar2 10
MAPKA Number
0

Autocommit Disj›lay 10 •
select *from student,

Results Explain Describe Sav+d SQL History

R 0 LL _NO NAM E NiARKS


1 Kapil 100
2 vijay
2 rows returned in 0.02 seconds s'V E ,» rt
15

INSERT COMMAND

AIM: To perform “insertion and deletion on tables” of project student database.


Insert command: This command is used to insert values in the table.

The SQL INSERT INTO clause has actually two parts – the first part specifying the
table we are inserting into and giving the list of columns we are inserting values for, the
second part specifying the values inserted in the column list from the first part.
Syntax: Insert into<tablename>values(‘<&fieldname1>’,’&<fieldname2>
‘,…..........); /; command: this command is used to enter the data in next
row.
Single row insertion

Syntax: INSERT INTO<tablename>[<column


list>] VALUES(<value>,<value> …);
Only one row can be added through this method and this method is applicable only when
we know the order of column in the table.
16

Delete command : this command is used to delete the data from the table. This
command can be used in following ways:
Syntax: To delete all the rows of a
table: Delete from<tablename>;

Example:

Syntax : To delete specific rows from the


table Delete from<tablename>
Where<condition>;
Example:
17

Drop table command: This command drops the table when you no longer need a table,
use the DROP TABLE statement to remove it from the database. When DBMS executes
this statement, it erases the table data and index(es) from the database and removes the
definition of the table reference by a FOREIGN KEY constraint from the other table.
Syntax:

Drop Table<tablename>;
Example:

UPDATE COMMAND
Aim: To “modify the contents and structures of tables”.
Update command: This command is used to update the data stored in table. Once there’s
data in the table, we might find that there is a need to modify the data. To do so, we can
use the UPDATE command, you can modify one or more values in one or more rows, and
you can base row selection on values in any tables to which you have SELECT access.
However, the UPDATE statement can have only one target table, meaning that the
UPDATE statement can change values in only at a time.
 Syntax:

Update<tablename>
18

Set<fieldname1>=<value>
Where<fieldname1>=’<value>’;

Alter table command: This is used to change the structure of a table, after we create a
table, we may need to change the structure because we omitted a column, the column
definition needs to be changed, or we need to remove columns. We can do this by using
the ALTER TABLE command.
Syntax:

Alter TABLE <tablename>


Modify(<fieldname>fieldtype(
<width>)); TO ADD NEW
ROWS:

Syntax:

Alter table<tablename>
Add(<fieldname>fieldtype(<width>));
Examples:
19
20

PRACTICAL - 4

Create table
CREATE TABLE is the keyword telling the database
system what you want to do. In this case, you want
to create a new table. The unique name or
identifier for the table follows the CREATE TABLE
statement. Then in brackets comes the list defining
each column in the table and what sort of data type
it is.

Syntax

The basic syntax of the CREATE TABLE


statement is as follows −
CREATE TABLE table_name(
column1 datatype,
column2 datatype,
column3 datatype,
.....
columnN datatype,
PRIMARY KEY( one or more columns )
);
CREATE TABLE is the keyword telling the
database system what you want to do. In this
case, you want to create a new table. The unique
name or identifier for the table follows the
CREATE TABLE statement.
Then in brackets comes the list defining each
column in the table and what sort of data type it
21

is. The syntax becomes clearer with the following


example.
A copy of an existing table can be created using
a combination of the CREATE TABLE statement
and the SELECT statement. You can check the
complete details at Create Table Using another
Table.

Example
The following code block is an example, which
creates a CUSTOMERS table with an ID as a
primary key and NOT NULL are the constraints
showing that these fields cannot be NULL while
creating records in this table −
SQL> CREATE TABLE CUSTOMERS(
ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR (25),
SALARY DECIMAL (18,2),
PRIMARY KEY (ID)
);
You can verify if your table has been created
successfully by looking at the message displayed
by the SQL server, otherwise you can use
the DESC command as follows −
SQL> DESC CUSTOMERS;
+---------+---------------------+---------+-----
+----------+-----------+
| Field | Type | Null | Key | Default |
Extra |
+---------+---------------------+---------+-----
+----------+-----------+
22

| ID | int(11) | NO | PRI | | |
| NAME | varchar(20) | NO | | | |
| AGE | int(11) | NO | | | |
| ADDRESS| char(25)| YES | | NULL | |
| SALARY| decimal(18,2) | YES | | NULL |
|
+---------+---------------------+----------+-----
+---------+------------+
5 rows in set (0.00 sec)
Now, you have CUSTOMERS table available in
your database which you can use to store the
required information related to customers.

Insert

Insert is a widely-used command in the


Structured Query Language (SQL) data
manipulation language (DML) used by SQL
Server and Oracle relational databases. The
insert command is used for inserting one or more
rows into a database table with specified table
column values.

Syntax
23

There are two basic syntaxes of the INSERT


INTO statement which are shown below.
INSERT INTO TABLE_NAME (column1, column2,
column3,...columnN)
VALUES (value1, value2, value3,...valueN);
Here, column1, column2, column3,...columnN
are the names of the columns in the table into
which you want to insert the data.
You may not need to specify the column(s) name
in the SQL query if you are adding values for all
the columns of the table. But make sure the
order of the values is in the same order as the
columns in the table.
The SQL INSERT INTO syntax will be as follows

INSERT INTO TABLE_NAME VALUES
(value1,value2,value3,...valueN);
Example
The following statements would create six
records in the CUSTOMERS table.
INSERT INTO CUSTOMERS
(ID,NAME,AGE,ADDRESS,SALARY)
VALUES (1,'Ramesh',32,'Ahmedabad',2000.00);

INSERT INTO CUSTOMERS


(ID,NAME,AGE,ADDRESS,SALARY)
VALUES (2,'Khilan',25,'Delhi',1500.00);

INSERT INTO CUSTOMERS


(ID,NAME,AGE,ADDRESS,SALARY)
VALUES (3,'kaushik',23,'Kota',2000.00);

INSERT INTO CUSTOMERS


(ID,NAME,AGE,ADDRESS,SALARY)
VALUES (4,'Chaitali',25,'Mumbai',6500.00);
24

INSERT INTO CUSTOMERS


(ID,NAME,AGE,ADDRESS,SALARY)
VALUES (5,'Hardik',27,'Bhopal',8500.00);

INSERT INTO CUSTOMERS


(ID,NAME,AGE,ADDRESS,SALARY)
VALUES (6,'Komal',22,'MP',4500.00);
You can create a record in the CUSTOMERS table
by using the second syntax as shown below.
INSERT INTO CUSTOMERS
VALUES (7, 'Muffy', 24, 'Indore', 10000.00 );
All the above statements would produce the
following records in the CUSTOMERS table as
shown below.
+----+----------+-----+-----------+----------+
| ID | NAME | AGE | ADDRESS | SALARY |
+----+----------+-----+-----------+----------+
|1|Ramesh|32|Ahmedabad|2000.00|
|2|Khilan|25|Delhi|1500.00|
|3|kaushik|23|Kota|2000.00|
|4|Chaitali|25|Mumbai|6500.00|
|5|Hardik|27|Bhopal|8500.00|
|6|Komal|22| MP |4500.00|
|7|Muffy|24|Indore|10000.00|
+----+----------+-----+-----------+----------+
25

Check
The CHECK constraint is used to limit the value
range that can be placed in a column. If you define
a CHECK constraint on a table it can limit the
values in certain columns based on values in other
columns in the row.

Syntax
CREATE TABLE pets(
ID INT NOT NULL,
Name VARCHAR(30) NOT NULL,
Breed VARCHAR(20) NOT NULL,
Age INT,
GENDER VARCHAR(9),
PRIMARY KEY(ID),
Check(GENDER in ('Male', 'Female', 'Unknown'));
Example
Let's look at an example of how to use the CREATE
TABLE statement in SQL Server to create a check
constraint.
For example:
26

CREATE TABLE employees


(employee_id INT NOT NULL,
last_name VARCHAR(50) NOT NULL,
first_name VARCHAR(50),
salary MONEY,
CONSTRAINT check_employee_id
CHECK (employee_id BETWEEN 1 and 10000)
);

PRACTICAL - 5

Delete command
MySQL DELETE command is used to delete rows
that are no longer required from the database
tables. It deletes the whole row from the table and
returns count of deleted rows. Delete command
27

comes in handy to delete temporary or obsolete


data from your database.
Syntax
DELETE FROM table_name WHERE condition;
Example
Consider the CUSTOMERS table having the
following records −
+----+----------+-----+-----------+----------+
| ID | NAME | AGE | ADDRESS | SALARY |
+----+----------+-----+-----------+----------+
| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |
| 2 | Khilan | 25 | Delhi | 1500.00 |
| 3 | kaushik | 23 | Kota | 2000.00 |
| 4 | Chaitali | 25 | Mumbai | 6500.00 |
| 5 | Hardik | 27 | Bhopal | 8500.00 |
| 6 | Komal | 22 | MP | 4500.00 |
| 7 | Muffy | 24 | Indore | 10000.00 |
+----+----------+-----+-----------+----------+

The following code has a query, which will DELETE


a customer, whose ID is 6.
SQL> DELETE FROM CUSTOMERS
WHERE ID =6;

Now, the CUSTOMERS table would have the


following records.
+----+----------+-----+-----------+----------+
| ID | NAME | AGE | ADDRESS | SALARY |
+----+----------+-----+-----------+----------+
| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |
| 2 | Khilan | 25 | Delhi | 1500.00 |
| 3 | kaushik | 23 | Kota | 2000.00 |
| 4 | Chaitali | 25 | Mumbai | 6500.00 |
| 5 | Hardik | 27 | Bhopal | 8500.00 |
| 7 | Muffy | 24 | Indore | 10000.00 |
+----+----------+-----+-----------+----------+

If you want to DELETE all the records from the


CUSTOMERS table, you do not need to use the
WHERE clause and the DELETE query would be as
follows −
SQL> DELETE FROM CUSTOMERS;
28

Now, the CUSTOMERS table would not have any record.

Update command
UPDATE command is used to update any record of
data in a table. Following is its general syntax,
UPDATE table_name SET column_name =
new_value WHERE some_condition; ... In the
above statement, if we do not use the WHERE
clause, then our update query will update age for
all the columns of the table to 18.

Syntax
UPDATE table_name SET column_name =
new_value WHERE some_condition

Example

ROLL_N
O NAME ADDRESS PHONE Age

XXXXXXXX
1 Ram Delhi XX 18

2 RAMES GURGAO XXXXXXXX 18


29

ROLL_N
O NAME ADDRESS PHONE Age

H N XX

XXXXXXXX
3 PRATIK ROHTAK XX 20

XXXXXXXX
4 SURESH Delhi XX 18

XXXXXXXX
5 PRATIK ROHTAK XX 20

RAMES GURGAO XXXXXXXX


6 H N XX 18

Updating multiple columns:


 Update the columns NAME to ‘PRATIK’ and
ADDRESS to ‘SIKKIM’ where ROLL_NO is 1.
UPDATE Student SET NAME = 'PRATIK', ADDRESS
= 'SIKKIM' WHERE ROLL_NO = 1;
Output:
The above query will update two columns in the
first row and the table Student will now look like,
ROLL_N
O NAME ADDRESS PHONE Age
XXXXXXXXX
1 PRATIK SIKKIM X 18
30

ROLL_N
O NAME ADDRESS PHONE Age
RAMES GURGAO XXXXXXXXX
2 H N X 18

XXXXXXXXX
3 PRATIK ROHTAK X 20

SURES XXXXXXXXX
4 H Delhi X 18

XXXXXXXXX
5 PRATIK ROHTAK X 20

RAMES GURGAO XXXXXXXXX


6 H N X 18

You might also like