Professional Documents
Culture Documents
PRACTICAL FILE OF
MERI
COLLEGE
SUBMITTED TO - SUBMITTED BY –
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
PRACTICAL-1
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.
Advantage of DBMS:
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.
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
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.
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.
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.
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
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.
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
Tables
Queries
Relationships
Macros
Forms
Reports
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
Benefits:
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
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.
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.
Embedded SQL: SQL provides the feature of embedding host languages such as C,
COBOL, and Java for query from their language at runtime.
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.
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
<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;
Autocommit Disj›lay 10 •
select *from student,
INSERT COMMAND
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
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:
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:
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
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
Syntax
23
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
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
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
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
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