You are on page 1of 18

DATABASE MANAGEMENT SYSTEM

ETCS 357






Faculty: Student Name:
Miss Prerna Sharma Sandeep Singh Gulia

Roll No : 00196402811
Semester : V (B.Tech ECE)
Group : 5E789
















Maharaja Agrasen Institute Of Technology
Sector 22, Rohini, New Delhi 110085
(Affiliated to Guru Gobind Singh Indraprastha University)

INDEX
PAPER CODE : ETEC 357
Name of the student : Sandeep Singh Gulia
University Roll No. : 00196402811
Branch : B.Tech ECE (II
nd
Shift)
Section/ Group : 5E789

PRACTICAL DETAILS
S. No. Program
Submission
Date
Teachers
Signature
Remarks


















EXPERIMENT NO: 01 Date: 12
th
Aug. 2013

AIM: INTRODUCTION TO DATABASE MANAGEMENT SYSTEM & STANDARD QUERY
LANGUAGE (SQL).

A database is a collection of related files that are usually integrated, linked or cross-referenced to one
another.
The advantage of a database is that data and records contained in different files can be easily organized
and retrieved using specialized database management software called a database management system
(DBMS) or database manager.
A database management system is a set of software programs that allows users to create, edit and update
data in database files, and store and retrieve data from those database files.
Data in a database can be added, deleted, changed, sorted or searched all using a DBMS. If you were an
employee in a large organization, the information about you would likely be stored in different files that
are linked together. One file about you would pertain to your skills and abilities, another file to your
income tax status, another to your home and office address and telephone number, and another to your
annual performance ratings. By cross-referencing these files, someone could change a person's address in
one file and it would automatically be reflected in all the other files. DBMSs are commonly used to
manage:
Membership and subscription mailing lists
Accounting and bookkeeping information
The data obtained from scientific research
Customer information
Inventory information
Personal records
Library information

ADVANTAGES OF DATABASE MANAGEMENT SYSTEM

Improved availability: One of the principle advantages of a DBMS is that the same information can
be made available to different users.
Minimized redundancy: The data in a DBMS is more concise because, as a general rule, the
information in it appears just once. This reduces data redundancy, or in other words, the need to
repeat the same data over and over again. Minimizing redundancy can therefore significantly reduce
the cost of storing information on hard drives and other storage devices. In contrast, data fields are
commonly repeated in multiple files when a file management system is used.
Accuracy: Accurate, consistent, and up-to-date data is a sign of data integrity. DBMSs foster data
integrity because updates and changes to the data only have to be made in one place. The chances of
making a mistake are higher if you are required to change the same data in several different places
than if you only have to make the change in one place.
Program and file consistency: Using a database management system, file formats and system
programs are standardized. This makes the data files easier to maintain because the same rules and
guidelines apply across all types of data. The level of consistency across files and programs also
makes it easier to manage data when multiple programmers are involved.
User-friendly: Data is easier to access and manipulate with a DBMS than without it. In most cases,
DBMSs also reduce the reliance of individual users on computer specialists to meet their data needs.
Improved security: As stated earlier, DBMSs allow multiple users to access the same data resources.
This capability is generally viewed as a benefit, but there are potential risks for the organization.
Some sources of information should be protected or secured and only viewed by select individuals.
Through the use of passwords, database management systems can be used to restrict data access to
only those who should see it.

TYPES OF DATABASES:

1. Object-oriented databases: Able to handle many new data types, including graphics, photographs,
audio, and video, object-oriented databases represent a significant advance over their other database
cousins. Hierarchical and network databases are all designed to handle structured data; that is, data that
fits nicely into fields, rows, and columns. They are useful for handling small snippets of information such
as names, addresses, zip codes, product numbers, and any kind of statistic or number you can think of. On
the other hand, an object-oriented database can be used to store data from a variety of media sources, such
as photographs and text, and produce work, as output, in a multimedia format.

2.Hierarchical databases commonly used on mainframe computers, have been around for a long time. It
is one of the oldest methods of organizing and storing data, and it is still used by some organizations for
making travel reservations. A hierarchical database is organized in pyramid fashion, like the branches of a
tree extending downwards. Related fields or records are grouped together so that there are higher-level
records and lower-level records, just like the parents in a family tree sit above the subordinated children.

3.Network database: are similar to hierarchical databases by also having a hierarchical structure. There
are a few key differences, however. Instead of looking like an upside-down tree, a network database looks
more like a cobweb or interconnected network of records. In network databases, children are called
members and parents are called owners. The most important difference is that each child or member can
have more than one parent (or owner).

4.Relational databases the relationship between data files is relational, not hierarchical. Hierarchical and
network databases require the user to pass down through a hierarchy in order to access needed data.
Relational databases connect data in different files by using common data elements or a key field. Data in
relational databases is stored in different tables, each having a key field that uniquely identifies each row.
Relational databases are more flexible than either the hierarchical or network database structures. In
relational databases, tables or files filled with data are called relations, tuples designates a row or record,
and columns are referred to as attributes or fields.







Structured Query Language (SQL):

SQL is a standard language for accessing and manipulating databases.

What is SQL?

SQL stands for Structured Query Language
SQL lets you access and manipulate databases
SQL is an ANSI (American National Standards Institute) standard

What Can SQL do?

SQL can execute queries against a database
SQL can retrieve data from a database
SQL can insert records in a database
SQL can update records in a database
SQL can delete records from a database
SQL can create new databases
SQL can create new tables in a database
SQL can create stored procedures in a database
SQL can create views in a database
SQL can set permissions on tables, procedures, and views

Database Tables
A database most often contains one or more tables. Each table is identified by a name (e.g.
"Customers" or "Orders"). Tables contain records (rows) with data.

SQL Statements
Most of the actions you need to perform on a database are done with SQL statements.The
following SQL statement selects all the records in the "Customers" table:

SELECT * FROM Customers;

Some database systems require a semicolon at the end of each SQL statement.Semicolon is the
standard way to separate each SQL statement in database systems that allow more than one SQL
statement to be executed in the same call to the server.







EXPERIMENT NO: 02 Date: 12
th
Aug. 2013

AIM: IMPLEMENT THE FOLLOWING COMMANDS:
1. CREATE TABLE
2. INSERT INTO
3. SELECT
4. UPDATE
5. ORDER BY
6. AND & OR
7. WHERE
8. DELETE

1. CREATE TABLE: The CREATE TABLE statement is used to create a table in a database. Tables are
organized into rows and columns, and each table must have a name.

SQL CREATE TABLE Syntax:

CREATE TABLE table_name
(
column_name1 data_type(size),
column_name2 data_type(size),
column_name3 data_type(size),
....
);

EXAMPLE:








2. INSERT INTO: The INSERT INTO statement is used to insert new records in a table.

SQL INSERT INTO Syntax:

INSERT INTO table_name (column1,column2,column3,...)
VALUES (value1,value2,value3,...);

EXAMPLE:


3. SELECT: The SELECT statement is used to select data from a database. The result is stored in a result
table, called the result-set.

SQL SELECT Syntax:

SELECT column_name,column_name
FROM table_name;

And

SELECT * FROM table_name;

Example:


4. UPDATE: The UPDATE statement is used to update existing records in a table.

SQL UPDATE Syntax:

UPDATE table_name
SET column1=value1,column2=value2,...
WHERE some_column=some_value;

EXAMPLE:

5. ORDER BY: The ORDER BY keyword is used to sort the result-set by one or more columns.The
ORDER BY keyword sorts the records in ascending order by default. To sort the records in a descending
order, you can use the DESC keyword.

SQL ORDER BY Syntax:

SELECT column_name,column_name
FROM table_name
ORDER BY column_name,column_name ASC|DESC;

EXAMPLE:


6.WHERE: The WHERE clause is used to extract only those records that fulfill a specified criterion.

SQL WHERE Syntax:

SELECT column_name,column_name
FROM table_name
WHERE column_name operator value;

EXAMPLE:



7. AND & OR: The AND operator displays a record if both the first condition AND the second condition
are true.The OR operator displays a record if either the first condition OR the second condition is true.

EXAMPLE:





8. DELETE: The DELETE statement is used to delete rows in a table.

SQL DELETE Syntax:

DELETE FROM table_name
WHERE some_column=some_value;

EXAMPLE:














EXPERIMENT NO: 03 Date: 26
th
Aug. 2013

AIM: Implement the BASIC AGGREGATE FUNCTIONS, PRIMARY KEY and
FOREIGN KEY constraints and following COMMANDS:
DROP TABLE TRUNCATE TABLE

a) DROP TABLE:
The DROP TABLE statement is used to delete a table.

SQL DROP TABLE Syntax:
DROP TABLE table_name;

b) TRUNCATE TABLE:
If we only want to delete the data inside the table, and not the table itself then, the TRUNCATE
TABLE statement is used.

SQL TRUNCATE TABLE Syntax:
TRUNCATE TABLE table_name;

Example:




c) PRIMARY KEY constraint:
The PRIMARY KEY constraint uniquely identifies each record in a database table.
Primary keys must contain unique values.
A primary key column cannot contain NULL values.
Each table should have a primary key, and each table can have only ONE primary key.
Oracle syntax:
column_name1 data_type(size) NOT NULL PRIMARY KEY,

d) FOREIGN KEY constraint:
A FOREIGN KEY in one table points to a PRIMARY KEY in another table.
The FOREIGN KEY constraint is used to prevent actions that would destroy links between
tables.
The FOREIGN KEY constraint also prevents invalid data from being inserted into the foreign key
column, because it has to be one of the values contained in the table it points to.

Oracle syntax:
column_name data_type(size) REFERENCES table_name(primary_key_name),

Exapmle:
Note that the "P_Id" column in the "Orders" table points to the "P_Id" column in the "Tablet"
table.
The "P_Id" column in the "Tablet" table is the PRIMARY KEY in the "Tablet" table.
The "P_Id" column in the "Orders" table is a FOREIGN KEY in the "Orders" table.




e) BASIC AGGREGATE FUNCTIONS:

1. AVG( )
The AVG( ) function returns the average value of a numeric column.

SQL AVG( ) Syntax:
SELECT AVG(column_name) FROM table_name;

Example:


2. COUNT( )
The COUNT( ) function returns the number of rows that matches a specified criteria.

SQL COUNT( ) Syntax:

The COUNT(column_name) function returns the number of values (NULL values will not be
counted) of the specified column:

SELECT COUNT(column_name) FROM table_name;

The COUNT(*) function returns the number of records in a table:

SELECT COUNT(*) FROM table_name;

The COUNT(DISTINCT column_name) function returns the number of distinct values of the
specified column:

SELECT COUNT(DISTINCT column_name) FROM table_name;

Example:


3. MAX( )
The MAX() function returns the largest value of the selected column.

SQL MAX() Syntax:

SELECT MAX(column_name) FROM table_name;

4. MIN( )
The MIN() function returns the smallest value of the selected column.

SQL MIN() Syntax:
SELECT MIN(column_name) FROM table_name;

Example:


5. SUM( )
The SUM() function returns the total sum of a numeric column.

SQL SUM() Syntax:
SELECT SUM(column_name) FROM table_name;

Example:


6. FIRST( )
The FIRST() function returns the first value of the selected column.

SQL FIRST() Syntax:
SELECT FIRST(column_name) FROM table_name;

Note: The FIRST() function is only supported in MS Access.

Oracle Syntax:

SELECT column_name FROM table_name
ORDER BY column_name ASC
WHERE ROWNUM <=1;

Example:


7. LAST( )
The LAST() function returns the last value of the selected column.

SQL LAST() Syntax:
SELECT LAST(column_name) FROM table_name;

Note: The LAST() function is only supported in MS Access.

Oracle Syntax:

SELECT column_name FROM table_name
ORDER BY column_name DESC
WHERE ROWNUM <=1;

You might also like