Sie sind auf Seite 1von 31

Laboratory File

On
DATABASE MANAGEMENT SYSTEM
PAPER CODE: ETEC-455
Submitted for
Bachelor of Technology
In
ELECTRONICS AND COMMUNICATION

Dr. Akhilesh Das Gupta Institute of Technology and Management

Submitted to: Submitted by:


Ms. Anjani Gupta Kartik Joshi
Assistant Professor ECE-F4(7thSem)
Department of ECE 44415602817
S.NO. PRACTICAL DATE REM
ARK
S
Introduction to DBMS & Oracle. 27/08/20
1
Installation of MySQL 3/09/20
2
Designa database andcreate required tables. 10/09/20
3
Apply the constraints like Primary Key, Foreign Key, 17/09/20
4
NOT NULL to the tables
Write a SQL statement for implementing ALTER, 24/09/20
5 UPDATE and DELETE
Design Write the queries to implement the joins 01/10/20
6
Write the queries for implementing the following functions: 08/10/20
7 MAX(), MIN(), AVG(), COUNT().

Write the queries to implement the concept of integrity 15/10/20


8 constrains.

Write the queries to create the views 5/11/20


9
Perform the following operations for demonstrating the insertion, 26/11/20
10 updation, and deleting using the referential integrity constraints.

Kartik Joshi 44415602817 F4 ECE


EXPERIMENT-01

AIM: Introduction to DBMS & Oracle.


Database Management System
• This model is like a hierarchical tree structure, used to construct a hierarchy of records inthe form
of nodes and branches.
• The data elements present in the structure have Parent-Childrelationship.
• Closely related information in the parent-child structure is stored together as a logicalunit.
• A parent unit may have many child units, but a child is restricted to have only one parent.

The drawbacks of this model are:


• The hierarchical structure is not flexible to represent all the relationship proportions,
• which occur in the real world.
• It cannot demonstrate the overall data model for the enterprise because of the non-availability of
actual data at the time of designing the data model.
• It cannot represent the Many-to-Many relationship.

Network Model
• It supports the One-To-One and One-To-Many types only. The basic objects in this model
areData Items, Data Aggregates, Records and Sets.
• It is an improvement on the Hierarchical Model. Here multiple parent-child relationships areused.
• Rapid and easy access to data is possible in this model due to multiple access paths to thedata
elements.

Relational Model
• Does not maintain physical connection between relations.
• Data is organized in terms of rows and columns in a table.
• The position of a row and/or column in a table is of no importance.
• The intersection of a row and column must give a single value.

Features of an RDBMS
• The ability to create multiple relations and enter data into them.
• An attractive query language.
• Retrieval of information stored in more than one table.
• An RDBMS product has to satisfy at least Seven of the 12 rules of Codd to be acceptedas a full-
fledged RDBMS.

Relational Database Management System

Kartik Joshi 44415602817 F4 ECE


RDBMS is acronym for Relation Database Management System. Dr. E. F. Codd first
introduced the Relational Database Model in 1970. The Relational model allows data to berepresented in
a simple row- column. Each data field is considered as a column and each record isconsidered as a row.
Relational Database is more or less similar to Database Management System.In relational model there is
relation between their data elements. Data is stored in tables. Tableshave columns, rows and names.
Tables can be related to each other if each has a column with acommon type of information. The most
famous RDBMS packages are Oracle, Sybase andInformix.
Simple example of Relational model is as follows :

Student Details Table

Roll_no Sname S_Address

1 Rahul Satelite

2 Sachin Ambawadi

3 Saurav Naranpura

Student Marksheet Table

Rollno Sub1 Sub2 Sub3

1 78 89 94

2 54 65 77

3 23 78 46

Here, both tables are based on students details. Common field in both tables is Rollno. So we

can say both tables are related with each other through Rollno column.

Degree of Relationship

Kartik Joshi 44415602817 F4 ECE


• One to One (1:1)
• One to Many or Many to One (1:M / M: 1)
• Many to Many (M: M)
The Degree of Relationship indicates the link between two entities for a specified occurrence ofeach.

One to One Relationship: (1:1)

11

Student Has Roll No.

One student has only one Rollno. For one occurrence of the first entity, there can be, at the mostone
related occurrence of the second entity, and vice-versa.

One to Many or Many to One Relationship: (1:M/M: 1)

1M

Course Contains Students

As per the Institutions Norm, One student can enroll in one course at a time however, in onecourse, there
can be more than one student.

For one occurrence of the first entity there can exist many related occurrences of the secondentity and for
every occurrence of the second entity there exists only one associated occurrenceof the first.

Many to Many Relationship: (M:M)

MM

Students Appears Tests

The major disadvantage of the relational model is that a clear-cut interface cannot be
determined.Reusability of a structure is not possible. The Relational Database now accepted model on
whichmajor database system are built.

Oracle has introduced added functionality to this by incorporated object-oriented capabilities.

Now it is known is as Object Relational Database Management System (ORDBMS). Object-oriented


concept is added in Oracle8.

Kartik Joshi 44415602817 F4 ECE


Some basic rules have to be followed for a DBMS to be relational. They are known as Codd’srules,
designed in such a way that when the database is ready for use it encapsulates therelational theory to its
full potential. These twelve rules are as follows.

E. F. Codd Rules
1. The Information Rule

All information must be store in table as data values.

2. The Rule of Guaranteed Access

Every item in a table must be logically addressable with the help of a table name.

3. The Systematic Treatment of Null Values

The RDBMS must be taken care of null values to represent missing or

inapplicable information.

4. The Database Description Rule

A description of database is maintained using the same logical structures with

which data was defined by the RDBMS.

5. Comprehensive Data Sub Language

According to the rule the system must support data definition, view definition, data

manipulation, integrity constraints, authorization and transaction management

operations.

6. The View Updating Rule

All views that are theoretically updatable are also updatable by the system.

7. The Insert and Update Rule

This rule indicates that all the data manipulation commands must be operational

on sets of rows having a relation rather than on a single row.

8. The Physical Independence Rule

Application programs must remain unimpaired when any changes are made in storagerepresentation or
access methods.

9. The Logical Data Independence Rule

Kartik Joshi 44415602817 F4 ECE


The changes that are made should not affect the user’s ability to work with the

Data.The change can be splitting table into many more tables.

10. The Integrity Independence Rule

The integrity constraints should store in the system catalog or in the database.

11. The Distribution Rule

The system must be access or manipulate the data that is distributed in other systems.

12. The Non-subversion Rule

If a RDBMS supports a lower level language then it should not bypass any

integrity constraints defined in the higher level.

Object Relational Database Management System

Oracle8 and later versions are supported object-oriented concepts. A structure once created can bereused
is the fundamental of the OOP’s concept. So we can say Oracle8 is supported ObjectRelational model,
Object - oriented model both. Oracle products are based on a concept known asa client-server technology.
This concept involves segregating the processing of an applicationbetween two systems. One performs all
activities related to the database (server) and the otherperforms activities that help the user to interact with
the application (client). A client or front-enddatabase application also interacts with the database by
requesting and receiving information fromdatabase server. It acts as an interface between the user and the
database.The database server or back end is used to manage the database tables and also respond to
clientrequests.

Kartik Joshi 44415602817 F4 ECE


Introduction to ORACLE
ORACLE is a powerful RDBMS product that provides efficient and effective solutions for majordatabase
features. This includes:

• Large databases and space management control


• Many concurrent database users
• High transaction processing performance
• High availability
• Controlled availability
• Industry accepted standards
• Manageable security
• Database enforced integrity
• Client/Server environment
• Distributed database systems
• Portability
• Compatibility
• Connectivity
An ORACLE database system can easily take advantage of distributed processing by using itsClient/
Server architecture. In this architecture, the database system is divided into two parts:

A front-end or a client portion


The client executes the database application that accesses database information and interacts withthe user.

A back-end or a server portion


The server executes the ORACLE software and handles the functions required for concurrent,shared data
access to ORACLE database.

Kartik Joshi 44415602817 F4 ECE


Experiment-02

AIM:Installation of MySQL .
PROCEDURE : Steps for installing MySQL
Step1: “https://dev.mysql.com/downloads/installer/” . Go through this link &
install the MYSQL installer 8.0.21 (windows 32 bit MSI Installer).

Step2:This is MySQL Server 8.0 setup wizard. The setup wizard will install
MySQL Server 8.0 release 8.0.21 on your computer. To continue, click next.

Kartik Joshi 44415602817 F4 ECE


Step3: This wizard is ready to begin installation. Destination folder will be in

“C:\Program Files\MySQL\MySQL Server 8.0\”. To continue, click


next.

Step4:The program features you selected are being installed. Please wait while the
setup wizard installs MySQL 8.0. This may take several minutes.

Step5:To continue, click next. Wizard Completed. Setup has finished installing
MySQL 8.0. Check the configure the MySQL server now to continue. Click
Finish to exit the wizard

Kartik Joshi 44415602817 F4 ECE


Step6:The configuration wizard will allow you to configure the MySQL Server 8.0
server instance.

Step7: this method asking for authentication method (prefer the legacy of MYSQL
5.x Compatibility)

Kartik Joshi 44415602817 F4 ECE


Step8:Please set the security options by entering the root password and confirm
retype the password& press check. continue, click next.

Step9:Select a standard configuration and this will use a general purpose


configuration for the server that can be tuned manually. To continue, click next.

Kartik Joshi 44415602817 F4 ECE


Step10: Again asking for password for the connection to the server.

Step11:Processing configuration in progress.

Kartik Joshi 44415602817 F4 ECE


Step12:Configuration file created. Windows service MySQL5 installed. Press
finish to close the wizard.

Kartik Joshi 44415602817 F4 ECE


Experiment No. 3

TO CREATE A DATABASE

1.1 Objective 1.2 Theory 1.3 Program 1.4 Software Required 1.5 Result 1.6 Pre-Requisite 1.7 Post-
Requisite

1.1. OBJECTIVE: Design a database and create required tables.

1.2. THEORY:
A database is a shared, integrated computer structure the stores a collection of:
1. End-user data, that is, raw facts of interest to the end user.
2. Metadata or data about data, through which the end-user data are integrated and managed.
A DBMS can support many different kinds of databases. Database can be classified according to
the number of users, the database locations, and the expected type and extent of use. The number
of users determines whether the database is classified as single-user or multi-user. A single-user
database supports only one user at a time. In other words, if user A is using the database, users B
and C must wait until user A is done. I contrast, a multiuser database supports multiple users at the
same time.

1.3. PROGRAM:
create database corporation;
create table company
(
cmp_idvarchar(5) primary key,
cmp_namevarchar(30) not null,
no_of_studint
);

1.4 SOFTWARE REQUIRED: MySQL on Ubuntu

1.5. RESULT:

Kartik Joshi 44415602817 F4 ECE


1.6. PRE-REQUISITE:

Q.1. What is a database?


Q.2. What is Database Management System?

1.7. POST-REQUISITE:

Q.1. Explain the steps to create a database in PL/SQL?


Q.2. Explain how do we create a table and insert values into a table?

Kartik Joshi 44415602817 F4 ECE


Experiment No. 4

TO APPLY CONSTRAINTS

2.1 Objective 2.2 Theory 2.3 Program 2.4 Software Required 2.5 Pre-Requisite 2.6 Post-Requisite

2.1. OBJECTIVE: Apply the constraints like Primary Key, Foreign Key, NOT NULL to the tables.

2.2. THEORY:
Constraints are conditions that must hold on all valid relation instances.

Primary Key: If an attribute is chosen to be a primary key it means that its values must not
change. Primary keys cannot be duplicate. In a primary key all the record in that column must be
unique and no NOT NULL value. A primary key is a minimum super key.
Foreign Key: Sometimes the information stored in a relation is linked to the information stored
in another relation. A foreign key is an attribute whose values match the primary key values in the
related table. A foreign key is a copy of primary key of another table. This key connects to
another table when a relationship is being established.
NOT NULL: When this constraint is applied to an attribute this means the records can be
duplicate but there cannot be a NULL value in the column.

2.3. PROGRAM:

create table company


(
cmp_idvarchar(5) primary key,
cmp_namevarchar(30) not null,
no_of_studint
);
create table Tnp

(stud_idvarchar(30) primary key,

namevarchar(30) not null,

cmp_idvarchar(5) references company);

2.4. SOFTWARE REQUIRED:

MySQL on Ubuntu

2.5.RESULT:

Kartik Joshi 44415602817 F4 ECE


2.6.PRE-REQUISITE:

Q1. What are Keys in DBMS?

Q2. What do you mean by constraints?

2.7.POST-REQUISITE:

Q1. What is entity integrity constraints?

Q2. Explain NOT NULL, Primary Key and UNIQUE constraints.

Experiment No. 5

Kartik Joshi 44415602817 F4 ECE


TO USE ALTER, UPDATE AND DELETE COMMANDS

3.1 Objective 3.2 Theory 3.3 Program 3.4 Software Required 3.5 Result 3.6 Pre-Requisite 3.7 Post-
Requisite

3.1. OBJECTIVE: Write a SQL statement for implementing ALTER, UPDATE and DELETE.

3.2. THEORY:

Data Definition Language (DDL) is the part of SQL that allows the database user to create and
restructure database objects, such as ALTER command is used to modify an existing table.

Data Manipulation Language (DML) is the part of SQL used to manipulate data within objects of a
relational database. Basic commands of DML are UPDATE command which is used to change or
modify values in a table and DELETE command which is used.

3.3. PROGRAM:

updateTnp

setsal=’200000’

wherestud_id=’2563’;

alter table Tnp

order by asc;

alter table Tnp

modify(stud_idvarchar(5));

delete from Tnp

wherestud_id=’2563’;

3.4.SOFTWARE REQUIRED:

MySQL on Ubuntu.

Kartik Joshi 44415602817 F4 ECE


3.5. RESULT:

3.6. PRE-REQUISITE:

Q 1. List all the categories of SQL commands.


Q 2. Define DDL and DML commands.
3.7. POST-REQUISITE:

Q.1. What is the difference between UPDATE and ALTER commands?

Kartik Joshi 44415602817 F4 ECE


Q.2. What is the difference between DROP and DELETE commands?

Experiment No. 6

TO IMPLEMENT JOINS

Kartik Joshi 44415602817 F4 ECE


4.1 Objective 4.2 Theory 4.3 Program 4.4 Software Required 4.5 Result 4.6 Pre-Requisite 4.7
Post-Requisite

4.1. OBJECTIVE: Write the queries to implement the joins.

4.2. THEORY:

The SQL JOIN clause is used to combine from two or more tables in a database. A JOIN is a means
for combining fields from two tables by using values common to each.
If a SQL JOIN condition is omitted or invalid it will result in a Cartesian product.
There are different types of joins available in SQL:
• INNER JOIN
• LEFT JOIN
• RIGHT JOIN
• FULL JOIN
• SELF JOIN
• CARTESIAN JOIN

4.3. PROGRAM:

select * from Tnp,company

whereTnp.cmp_id=company.cmp_id;

4.4. SOFTWARE REQUIRED: MySQL on Ubuntu

4.5. RESULT:

Kartik Joshi 44415602817 F4 ECE


4.6. PRE-REQUISITE:

Q.1. What do you mean by join?


Q.2. What are the different types of joins?
4.7. POST-REQUISITE:

Q.1. How can we implement SELF join?


Q.2. Explain different types of outer join.

Experiment No. 7

Kartik Joshi 44415602817 F4 ECE


TO IMPLEMENT AGGREGATE FUNCTIONS

5.1 Objective 5.2 Theory 5.3 Program 5.4 Software Required 5.5 Result 5.6 Pre-Requisite 5.7
Post-Requisite

5.1. OBJECTIVE: Write the queries to implement the following functions: MAX (), MIN (), AVG (),
COUNT().

5.2. THEORY:

• MAX (): This function chooses the maximum value among the values in the attribute chosen.
• MIN (): This function chooses the least value among all the values in the attribute chosen.
• AVG (): This function calculates the average of the attribute chosen.
• COUNT (): This function counts the number of tuples for a given attribute.

5.3. PROGRAM:

select MAX(sal) from Tnp;

select MIN(sal) from Tnp;

select AVG(sal) from Tnp;

select count(*) from Tnp;

5.4. SOFTWARE REQUIRED:

MySQL on Ubuntu.

Kartik Joshi 44415602817 F4 ECE


5.5. RESULT:

5.6. PRE- REQUISITE:

Q.1. What do you mean by aggregate functions?


Q.2. List all types of aggregate functions.
5.7. POST- REQUISITE:

Q.1. How can you implement aggregate functions in you MySQL?


Q.2. Explain how count can be used?

Kartik Joshi 44415602817 F4 ECE


Experiment No. 8

TO IMPLEMENT INTEGRITY CONSTRAINTS

6.1 Objective 6.2 Theory 6.3 Program 6.4 Software Required 6.5 Result 6.6 Pre-Requisite 6.7 Post-
Requisite

6.1. OBJECTIVE: Write the queries to implement the concept of integrity constraints.

6.2. THEORY:

Integrity constraints ensure that changes made to the database by authorized users do not result in a
loss of data consistency. The allowed integrity constraints are:

• Not null: This make the records in a particular attribute not have a null value
• Unique: This makes the records to not have duplicate values and null value also used only
once.
• Check: This checks a given condition specified by the user

6.3. PROGRAM:

create table Tnp

(stud_idvarchar(30) primary key,

namevarchar(30) not null,

cmp_idvarchar(5) references company);

6.4. SOFTWARE REQUIRED:

MySQL on Ubuntu

Kartik Joshi 44415602817 F4 ECE


6.5. RESULT:

6.6. PRE-REQUISITE:

Q 1. What do you mean by integrity constraints?


6.7. POST-REQUISITE:

Q 1. What is referential integrity constraints?


Q 2. What is the difference between referential and entity integrity constraints?

Kartik Joshi 44415602817 F4 ECE


Experiment No. 9

TO CREATE THE VIEWS

7.1 Objective 7.2 Theory 7.3 Program 7.4 Software Required 7.5 Result 7.6 Pre-Requisite 7.7 Post-
Requisite

7.1. OBJECTIVE: Write the queries to create the views.

7.2. THEORY:

A view is nothing more than a SQL statement that is stored in the database with an associated name.
A view is actually a composition of a table in the form of a predefined SQL query. A view can
contain all rows of a table or select rows from a table. A view can be created from one or many tables
which depends on the written SQL query to create a view.
So, a view is a virtual table, through which a selective portion of the data from one or more tables can
be seen. Views do not contain data of their own.

7.3. PROGRAM:

create view result as select * from Tnp;

select * from result;

7.4. SOFTWARE REQUIRED: MySQL on Ubuntu

7.5. RESULT:

Kartik Joshi 44415602817 F4 ECE


7.6. PRE-REQUISITE:

Q 1. What is view?
Q 2. What are the advantages of creating a view?

7.7. POST REQUISITE:

Q 1. How can you implement a view?


Q 2. What is the syntax for creating a view?

Kartik Joshi 44415602817 F4 ECE


Experiment No. 10

TO USE REFERENTIAL INTEGRTY CONSTRAINTS

8.1 Objective 8.2 Theory 8.3 Program 8.4 Software Required 8.5 Result 8.6 Pre-Requisite 8.7 Post-
Requisite

8.1. OBJECTIVE: Perform the following operation for demonstrating the insertion, updation and
deletion using the referential integrity constraints.

8.2. THEORY:

Referential integrity refers when we want to ensure that a value that appears in one relation for a
given set of attributes also appears for certain set of attributes in another relation.

8.3. PROGRAM:

select * from Tnp,company

whereTnp.cmp_id=company.cmp_id;

8.4. SOFTWARE REQUIRED: MySQL ON Ubuntu

8.5. RESULT:

Kartik Joshi 44415602817 F4 ECE


8.6. PRE-REQUISITE:

Q 1. What is referential integrity constraints?


Q 2. How are referential integrity constraints used?
8.7. POST REQUISITE:

Q 1. What is the syntax for referential integrity constraints?


Q 2. Give a few examples how referential integrity constraints are used?

Kartik Joshi 44415602817 F4 ECE

Das könnte Ihnen auch gefallen