Institute of Management and Tech.: Partial Fulfilment of The Award of Degree of
Institute of Management and Tech.: Partial Fulfilment of The Award of Degree of
AND TECH.
PRACTICAL FILE
ON RDBMS(RELATIONAL DATABASE MANAGEMENT SYSTEM)
BATCH(2019-22)
GIVENTHETABLEEMPLOYEE(M.NO,NAME,SALARY,D
6 ESTINATION,DEPARTMENT ID) WRIGHT a query to
select a five highest paid employees from the table.
PRACTICAL 1
capabilities that enable IT teams and others to create, update, administer and
otherwise interact with a relational database. RDBMSes store data in the form of
Structured Query Language (SQL) to access the database. However, since SQL was
invented after the initial development of the relational model, it is not necessary for
RDBMS use.
The RDBMS is the most popular database system among organizations across the
MODELS
Data Models
Data Model is the modeling of the data description, data semantics, and consistency
constraints of the data. It provides the conceptual tools for describing the design of a
1
database at each level of data abstraction. Therefore, there are following four data
1) Relational Data Model: This type of model designs the data in the form of rows
and columns within a table. Thus, a relational model uses tables for representing data
and in-between relationships. Tables are also called relations. This model was initially
described by Edgar F. Codd, in 1969. The relational data model is the widely used
data as objects and relationships among them. These objects are known as entities,
and relationship is an association among these entities. This model was designed by
Peter Chen and published in 1976 papers. It was widely used in database designing. A
set of attributes describe the entities. For example, student_name, student_id describes
the 'student' entity. A set of the same type of entities is known as an 'Entity set', and
2
3) Object-based Data Model: An extension of the ER model with notions of
functions, encapsulation, and object identity, as well. This model supports a rich type
system that includes structured and collection types. Thus, in 1980s, various database
systems following the object-oriented approach were developed. Here, the objects are
4) Semistructured Data Model: This type of data model is different from the
other three data models (explained above). The semistructured data model
allows the data specifications at places where the individual data items of the
same type may have different attributes sets. The Extensible Markup Language,
also known as XML, is widely used for representing the semistructured data.
Although XML was initially designed for including the markup information to
the text document, it gains importance because of its application in the exchange
of data.
The data which is stored in the database at a particular moment of time is called an instance of
the database.
A database schema is the skeleton structure of the database. It represents the logical view of
A schema contains schema objects like table, foreign key, primary key, views, columns, data
A database schema can be represented by using the visual diagram. That diagram shows the
A database schema is designed by the database designers to help programmers whose software
will interact with the database. The process of database creation is called data modeling.
3
A schema diagram can display only some aspects of a schema like the name of record
type, data type, and constraints. Other aspects can't be specified through the schema
diagram. For example, the given figure neither show the data type of each data item
In the database, actual data changes quite frequently. For example, in the given figure,
the database changes whenever we add a new grade or add a student. The data at a
4
PRACTICAL 2
ER DIAGRAM
be an entity with attributes like address, name, id, age, etc. The address can be another
entity with attributes like city, street name, pin code, etc and there will be a
be
5
6
PRACTICAL 3
Consider the Company database with following tables
2.
3.
4.
5.
6.
7
SOLUTION:
1.
Creating a Database
2.
Viewing all databases
SHOW DATABASES;
3.
Viewing all Tables in a Database,
SHOW tables;
4.
Creating Tables (With and Without Constraints)
MGRSTARTDATE DATE);
Page 13
8
ADDRESS VARCHAR2 (20),
SALARY INTEGER,
NOTE: Once DEPARTMENT and EMPLOYEE tables are created we must alter
department
9
VALUES (‗RNSCSE06‘,‘NEHA‘,‘SN‘,‘BANGALORE‘,‘F‘, 800000);
01‘,‘RNSACC02‘);
Page 14
Update
SSN=‘RNSCSE05‘;
6.
COMMIT and ROLLBACK
10
Before concluding this section on Data Manipulation Language commands there are
two
further commands, which are very useful. Changes made to the database by INSERT,
UPDATE and DELETE commands are temporary until explicitly committed. This is
COMMIT;
On execution of this command all changes to the database made by you are made
commit.
A COMMIT does not apply to any DDL commands (eg CREATE TABLE,
CREATE INDEX, etc). These are automatically committed and cannot be rolled
back.
If you wished to rollback (ie undo) any changes made to the database since the
ROLLBACK;
A group of related SQL commands that all have to complete successfully or otherwise
be
rolled back, is called a transaction. Part of your research for Outcome 3 includes
11
PRACTICAL 4
Altering a table
SQL Server / MS Access: ALTER TABLE table_name. ALTER COLUMN
column_name datatype;
Dropping a table
All constraints and views that reference the column are dropped automatically, along
CONSTRAINTS;
Table altered.
DNAME VARCHAR2(10)
Trankcating a table
{ database_name.schema_name.table_name | schema_name.table_name | table_name }
[ , ...n ] ) ) ]
<range>::=<partition_number_expression>TO<partition_number_expression>
12
PRACTICAL 5
For a given EMPLOYEE tables
1.
Creating Views (With and Without Check Option),
2.
Selecting from a View
3.
Dropping Views,
SOLUTION:
SALARY INTEGER,
13
SQL> DESC EMPLOYEE;
Name Null?
Type
VARCHAR2(20)
FNAME
VARCHAR2(20)
LNAME
VARCHAR2(20)
ADDRESS
VARCHAR2(20)
SEX
CHAR(1)
SALARY
NUMBER(38)
SUPERSSN
VARCHAR2(20)
DNO
NUMBER(38)
VALUES (‘RNSCSE01‘,‘JAMES‘,‘SMITH‘,‘BANGALORE
14
VALUES (‘RNSCSE02‘,‘HEARN‘,‘BAKER‘,‘BANGALORE‘,‘M‘, 700000);
Creating View
The query that defines the sales_staffview references only rows in department 5.
Furthermore, the CHECK OPTION creates the view with the constraint (named
sales_staff_cnst) that INSERT and UPDATE statements issued against the view
cannot
15
1. Creating Views (With and Without Check Option)
3 FROM employee
4 WHERE dno =5
View created.
3. Drop View
16
PRACTICAL 6
Given the table EMPLOYEE (EmpNo, Name, Salary, Designation, DeptID) write a
QUERY to select the five highest paid employees from the table.
SOLUTION:
NAME VARCHAR(20),
SALARY NUMBER(7,2),
DESIGNATION VARCHAR(10),
DEPTID INTEGER);
17