Page 1
SRI RAMAKRISHNA ENGINEERING COLLEGE
[Educational Service: SNR Sons Charitable Trust]
[Autonomous Institution, Accredited by NAAC with ‘A’ Grade]
[Approved by AICTE and Permanently Affiliated to Anna University, Chennai]
[ISO 9001:2015 Certified and all eligible programmes Accredited by NBA]
Vattamalaipalayam, N.G.G.O. Colony Post, Coimbatore – 641 022.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Certified that this is the bonafide record of work done by
Mr./Ms.____________________________________________ in the
--------------------------------------------------------of this institutions for B.E – CSE III Semester
during Academic year 2021-2022.
Faculty In-Charge HOD-CSE
REGISTER NUMBER
1901002
Submitted for the IV semester B.E-CSE Practical Examination on
_______________ during the Academic year 2021-2022.
Internal Examiner Subject Expert
Page 2
Content
S. No Date Program Name Page Marks Signature of
No Obtained the Faculty
1 STUDY OF DATABASE 3
MANAGEMENT SYSTEM
2 DATA MODELS-ER 5
MODELS
3 ENHANCED ER-MODEL 7
4 RELATIONAL MODEL 10
5 DATA DEFINITION 12
LANGUAGE
6 DATA MANIPULATION 14
LANGUAGE
7 DCL COMMANDS 16
8 SQL OPERATORS 19
9 SQL - AGGREGATE 22
FUNCTIONS
10 SET OPERATIONS 28
Page 3
Ex. No.: 1
Date: STUDY OF DATABASE MANAGEMENT SYSTEM
AIM:
To study basic terms of database management systems.
DESCRIPTION:
DATA: It consists of facts and statistics stored or free flowing over a network. It is
row and unprocessed.
INFORMATION: Data becomes information when it is processed, turning to
meaningful information.
DATABASE: Collection of related data organized in a way that data can be
easily accessed, managed and updated. Databases can be software or hardware
based.
DATABASE MANAGEMENT SYSTEM (DBMS): A database management
system is a software system which facilitates the organisation of housed data into
a particular database architecture, be it relational document store, key value
stored.
ARCHITECTURE FOR DATABASE MANAGEMENT SYSTEM:
VIEW LOGICAL PHYSICA
LEVEL LEVEL L LEVEL
RELATIONAL DATABASE: A relational database is one which employs the
relational model, in which the raw data is organised into sets of tuples, and the
tuples are organised into relation. This relational model imposes structure on its
Page 4
contents, in contrast to unstructured semi-structured data of various NOSQL
architecture
STRUCTURED QUERY LANGUAGE (SQL): It is a relational database query
and manipulation language. Its power and flexibility allow for the creation of
databases and tables, manipulation and query of data.
NOSQL: It is an umbrella term, one which encompasses a number of different
technologies. NOSQL means “not only SQL” meaning that these solutions are
more flexible and less rigid in nature.
META DATA: This is the data about data. Metadata describes data relationships
and characteristics and is often referred to as a data dictionary.
DATA REDUNDANCY: It is a situation in a database in which copies of data are
housed in different places. The redundancy can be achieved if data is held in
multiple places in some databases.
ACID: It is an acronym storing a set of database transaction properties, namely
Atomicity, Consistency, isolation and Durability. The sets of steps which make up
a transaction must either be completed in a full or rolled black and consistent.
ATTRIBUTE: A database attribute is a characteristic of a database entity. An
attribute is a column in a database table, which itself is known as an entity.
QUERY: A database query is now using interact with a database. It is usually
written in SQL and can be either a select query or an action query.
ER MODEL: It is a collection of basic objects called entities and the relationship
among these entities. ER MODEL helps you to analyze data requirements
systematically to produce a well-designed database.
RESULT:
Thus, the basic terminologies in database management systems have been
studied.
Page 5
Ex. No.: 2
ER MODEL
Date:
AIM:
To draw an ER Diagram for any real time application.
DESCRIPTION:
Entity relationship diagram displays the relationships of entity sets stored in a
database. ER Diagram includes many specialized symbols, and its meanings
make this model unique. It helps to describe entities, attributes, relationships.
This model is based on three basic concepts of Entities, Attributes and
Relationships.
EXAMPLE:
The Flight Database:
The flight database stores details about an airline’s fleet, flights, and seat
bookings. Again, it’s a hugely simplified version of what a real airline would use,
but the principles are the same.
Consider the following requirements list:
o The airline has one or more airplanes.
o An airplane has a model number, a unique registration number, and the
capacity to take one or more passengers.
o An airplane flight has a unique flight number, a departure airport, a
destination airport, a departure date and time, and an arrival date and
time.
o Each flight is carried out by a single airplane.
o A passenger has given names, a surname, and a unique email address.
o A passenger can book a seat on a flight.
ER DIAGRAM:
Page 6
RESULT:
Thus, the ER Diagram for Flight ticket Database System was drawn successfully.
Ex. No.: 3
Page 7
Date: ENHANCED ER MODEL
AIM:
To draw an ENHANCED ER Diagram for TNCL application.
DESCRIPTION:
As the complexity of data increased in the late 1980s, it became more and more
difficult to use the traditional ER Model for database modelling. Hence some
improvements or enhancements were made to the existing ER Model to make it
able to handle the complex applications better.
Hence, as part of the Enhanced ER Model, along with other improvements, three
new concepts were added to the existing ER Model, they were: Generalization,
Specialization and Aggregation
Generalization:
Generalization is a bottom-up approach in which two lower level entities
combine to form a higher-level entity. In generalization, the higher-level
entity can also combine with other lower-level entities to make further
higher-level entities.
Specialization:
Specialization is opposite to Generalization. It is a top-down approach in
which one higher level entity can be broken down into two lower level
entities. In specialization, a higher-level entity may not have any lower-
level entity sets, it's possible.
Page 8
Aggregation:
Aggregation is a process when the relation between two entities is treated
as single.
In the above diagram, the relationship between Team and Player together, is
acting as an Entity, which is in relationship with another entity Captain. Now, the
players in the team should have a coach with the captain for the successful team
play.
EER DIAGRAM:
Page 9
RESULT:
Thus, the Enhanced ER Diagram for National Cricket League Database System
was drawn successfully.
Ex. No.: 4
RELATIONAL MODEL
Page 10
Date:
AIM:
To draw a relational model Diagram for the application Student Profile
management.
DESCRIPTION:
The Relational Model represents how data is stored in Relational Databases. A
relational database stores data in the form of relations (tables). This model is
based on these basic concepts. Attribute, Relation Schema, Tuple, Relation
Instance, Degree, Cardinality, Column, NULL Values.
Consider a relation STUDENT with attributes Roll No., Name, Address, Phone
and Age shown in Table
Attribute: Attributes are the properties that define a relation. e.g.; Roll No.,
Name.
Relation Schema: A relation schema represents the name of the relation with its
attributes.
e.g.: STUDENT (Roll No., name, address, phone and age) is relation schema for
STUDENT. If a schema has more than 1 relation, it is called Relational Schema.
Tuple: Each row in the relation is known as tuple. The above relation contains 4
tuples.
Relation Instance: The set of tuples of a relation at a particular instance of time
is called a relation instance. Table 1 shows the relation instance of STUDENT at
a particular time. It can change whenever there is insertion, deletion or updating
in the database.
Degree: The number of attributes in the relation is known as degree of the
relation. The STUDENT relation defined above has a degree.
Cardinality: The number of tuples in a relation is known as cardinality. The
STUDENT relation defined above has cardinality 4.
Column: Column represents the set of values for a particular attribute. The
column Roll No. is extracted from relation STUDENT.
NULL Values: The value which is not known or unavailable is called NULL
value. It is represented by blank space. e.g.; Phone of STUDENT having Roll No.
4 is NULL.
Relational Model:
Page 11
According to step 1:
STUDENTS (rollno, StName, address, age)
Student address (Student name, phone No)
In step 2 the relationship types are translated:
Student (rollno → name, rollno → name, address)
RELATIONAL MODEL DIAGRAM:
RESULT:
Thus, the relational model for the student profile management was created
successfully.
Ex. No.: 5
DDL COMMANDS
Date:
Page 12
AIM:
To write a SQL query and to perform DDL operations like creating a table, alter,
modify and drop.
DDL COMMANDS:
The Create Table Command: It defines each column of the table uniquely. Each
column has a minimum of three attributes, a name, data type and size.
Syntax:
Create table <table name> (<col1> <datatype>(<size>), <col2>
<datatype><size>));
Example: create table emp (empno number (4) primary key, ename char
(10));
Modifying the structure of tables:
Add new columns:
The Add command used to add a new column in an existing table.
Syntax:
Alter table <tablename> add(<new col><datatype(size),<new
col>datatype(size));
Example: alter table emp add(sal number(7,2));
Dropping a column from a table:
The drop column command is used to delete columns in an existing table.
Syntax:
Alter table <tablename> drop column <col>;
Example: alter table emp drop column sql;
Modifying existing columns:
The modify command is used to modify column data type.
Syntax:
Alter table <tablename> modify(<col><newdatatype>(<newsize>));
Example: alter table emp modify(ename varchar2(15));
Renaming the tables:
The rename command is used to change the name of the table.
Syntax:
Rename <oldtable> to <new table>;
Example: rename emp to emp1;
Truncating the tables:
Page 13
The Truncate command is used to delete complete data from an existing
table.
Syntax:
Truncate table <tablename>;
Example: trunc table emp1;
Destroying the tables:
The drop command is used to delete the table structure from the
database.
Syntax:
Drop table <tablename>;
Example: drop table emp;
RESULT:
Thus, the DDL commands have been executed successfully.
Ex. No.: 6
DML COMMANDS
Date:
AIM:
To study the various DML commands and implement them on the database.
DML COMMANDS:
DML commands are the most frequently used SQL commands and are used to
query and manipulate the existing database objects. Some of the commands are Insert,
Select, Update, Delete.
Page 14
INSERT COMMAND:
This is used to add one or more rows to a table. The values are separated by
commas and the data types char and date are enclosed in apostrophes. The
values must be entered in the same order as they are defined.
Syntax:
insert into table_name (column1, column2, column3, ...) values (value1,
value2, value3, ...);
SELECT COMMAND:
It is used to retrieve information from the table. It is generally referred to as
querying the table. We can either display all columns in a table or only specify
columns from the table.
Syntax:
Select * from <tablename>;
UPDATE COMMAND:
It is used to alter the column values in a table. A single column may be updated
or more than one column could be updated.
Syntax:
update table_name
set column1 = value1, column2 = value2,
where condition;
DELETE COMMAND:
After inserting rows in a table we can also delete them if required. The delete
command consists of a from clause followed by an optional where clause.
Syntax:
Delete from table_name where condition;
Page 15
RESULT:
Thus, the DML commands have been executed successfully.
Ex. No.: 7
DCL COMMANDS
Date:
AIM:
To study the various DCL commands and implement them on the database.
DESCRIPTION:
Page 16
DCL (Data Control Language) includes commands such as GRANT and
REVOKE which mainly deals with the rights, permissions and other controls of
the database system.
Examples of DCL commands:
GRANT-gives user’s access privileges to database.
REVOKE-withdraw user’s access privileges given by using the GRANT
command.
TCL (Transaction Control Language) commands can only use with DML
commands like INSERT, DELETE and UPDATE only.
These operations are automatically committed in the database that's why they
cannot be used while creating tables or dropping them.
Some commands that come under TCL:
o COMMIT
o ROLLBACK
o SAVEPOINT
COMMIT:
● Commit command is used to save all the transactions to the database.
● Syntax:
COMMIT;
Example:
Page 17
– ROLLBACK:
● Rollback command is used to undo transactions that have not already been saved to
the database.
● Syntax:
ROLLBACK;
Example:
SAVEPOINT:
It is used to roll the transaction back to a certain point without rolling back the entire
transaction.
Syntax:
SAVEPOINT SAVEPOINT_NAME;
Page 18
RESULT:
Thus, the DCL commands have been executed successfully.
Ex. No.: 8
SQL OPERATORS
Date:
AIM:
To study the SQL Query and to implement them on the database.
DESCRIPTION:
Operators are used to specify conditions in an SQL statement and to serve as
conjunctions for multiple conditions in a statement.
● Arithmetic operators
● Comparison operators
● Logical operators
Arithmetic operators
Page 19
These operators are used to perform operations such as addition, multiplication,
subtraction etc.
SELECT 40+20;
SELECT 40 - 20;
Comparison operators:
These operators are used to perform operations such as equal to, greater than, less
than etc.
Example (Using less than or equal to):
Logical operators:
The logical operators are used to perform operations such as OR, AND, IN, LIKE, ALL,
ANY, NOT, BETWEEN, etc.
Page 20
Example:
1.IN
2.ANY:
Page 21
RESULT:
Thus, the SQL commands have been executed successfully.
Ex. No.: 9
SQL AGGREGATE FUNCTIONS
Date:
AIM:
To write a SQL aggregate functions and to perform aggregate function.
DESCRIPTION:
A multiple row function works on multiple values. These functions are called
aggregate functions or group functions.
Ex: AVG (), SUM (), MIN (), MAX (), COUNT ()
– SUM:
SUM function returns total sum of a selected columns numeric values.
Syntax:
SELECT SUM(column_name) from table-name;
Example:
Page 22
– AVG():
It returns average value after calculating from values in a numeric column.
Syntax:
SELECT AVG(column_name) FROM table_name;
Example:
Page 23
– COUNT:
Count returns the number of rows present in the table either based on some
condition or without condition.
Example:
Page 24
– MIN()
The MIN() is used to find the minimum value of a certain column.
Syntax:
SELECT MIN(column_name) from table-name;
Example:
Page 25
– MAX()
The MAX() is used to find the maximum value of a certain column.
Example:
Page 26
RESULT:
Thus, the SQL aggregate functions commands have been executed successfully.
Ex. No.: 10
SET OPERATORS
Date:
AIM:
To study the various set operators and to implement them on the database.
DESCRIPTION:
SQL supports few Set operations which can be performed on the table data. These
are used to get meaningful results from data stored in the table, under different
special conditions.
1. UNION
2. UNION ALL
Page 27
3. INTERSECT
4. MINUS
UNION:
Union is an operation of combining the output of two SELECT statements.
UNION ALL:
This operation is similar to Union. But it also shows the duplicate rows.
Page 28
INTERSECT
Intersect operation is used to combine two SELECT statements, but it only returns the
records which are common from both SELECT statements. In case of Intersect the
number of columns and datatype must be same.
Page 29
MINUS
The Minus operation combines results of two SELECT statements and return only those
in the final result, which belongs to the first set of the result.
Page 30
RESULT:
Thus, the commands have been executed successfully.