You are on page 1of 8

Annexure II

Annexure-II

Second Year Computer Engineering

DATABASE MANAGEMENT SYSTEM


(22319)

Micro-Project

Topic - Execute queries using SELECT


command with WHERE and HAVING clause

Team Members:
Om Ghugare (30)
Abhishek Chaudhari (31)
Suyash Nangare (32)
Rohan Khachane (33)

DATABASE MANAGEMENT SYSTEM (22319) Page 1


Annexure II

Micro-Project Proposal
Execute queries using SELECT command with WHERE and HAVING clause:

1.0 Rationale

Database Management Systems (DBMS) are vital components of modern information systems.
Database applications are pervasive and range in size from small in-memory databases to terra
bytes or even larger in various applications domains. The course focuses on the fundamentals of
knowledgebase and relational database management systems, and the current developments in
database theory and their practice.

2.0 Aim Of Micro-Project


Creating a database with two tables holding specific data in its tuples. Executing
queries with the use of SELECT command with WHERE and HAVING clause to get a
desired output through certain conditions.

Method: Using Transformations.

3.0 Course Outcomes Addressed


a) Create and Manage Database using SQL.
b) Design Normalized database on given data.
c) Create and manage Data base using SQL command.
d) Write a SQL command for given data base.
e) Apply security and confidentiality on given database.
4.0 Literature Review
To satisfy the needs of users outside of business applications, DBMSs must be expanded to
offer services in two other dimensions, namely object management and knowledge management.
Object management entails efficiently storing and manipulating non-traditional data types such as
bitmaps, icons, text, and polygons. Object management problems abound in CAD and many other
engineering applications. Knowledge management entails the ability to store and enforce a
collection of rules that are part of the semantics of an application. Such rules describe integrity
constraints about the application, as well as allowing the derivation of data that is not directly stored
in the database.

A) SELECT COMMAND -
B) WHERE CLAUSE -
C) HAVING CLAUSE –

DATABASE MANAGEMENT SYSTEM (22319) Page 2


Annexure II

A) SELECT COMMAND -

A SELECT/COMMAND statement retrieves zero or more rows from one or


more database tables or database views. In most applications, SELECT is the most
commonly used data query language (DQL) command. As SQL is a declarative
programming language, SELECT queries specify a result set, but do not specify how to
calculate it. The database translates the query into a "query plan" which may vary between
executions, database versions and database software. This functionality is called the "query
optimizer" as it is responsible for finding the best possible execution plan for the query,
within applicable constraints.

Syntax:

Select *
from {table_name}
order by {unique_key}

Example:

SELECT * FROM
( SELECT
ROW_NUMBER() OVER (ORDER BY sort_key ASC) AS row_number,
columns
FROM tablename
) AS foo
WHERE row_number <= 11;

DATABASE MANAGEMENT SYSTEM (22319) Page 3


Annexure II

B) WHERE CLAUSE -

A WHERE clause in SQL specifies that a SQL Data Manipulation Language


(DML) statement should only affect rows that meet specified criteria. The criteria are expressed in the
form of predicates. WHERE clauses are not mandatory clauses of SQL DML statements, but can be
used to limit the number of rows affected by a SQL DML statement or returned by a query. In brief
SQL WHERE clause is used to extract only those results from a SQL statement, such as: SELECT,
INSERT, UPDATE, or DELETE statement. The WHERE clause is used in conjunction with SQL
DML statements

Syntax:

Select * or column1, column2, …………


from {table_name}
where condition;

Example:

SELECT * FROM
Customer
WHERE customer_id = 101;

DATABASE MANAGEMENT SYSTEM (22319) Page 4


Annexure II

C) HAVING CLAUSE -
A HAVING clause in SQL specifies that an SQL SELECT statement should only return rows where
aggregate values meet the specified conditions. It was added to the SQL language because
the WHERE keyword could not be used with aggregate functions.

The HAVING clause filters the data on the group row but not on the individual row.

To view the present condition formed by the GROUP BY clause, the HAVING clause is used.

Syntax:

SELECT column_name(s)
FROM {table_name}
WHERE condition
GROUP BY column_name(s)
HAVING condition

Example:

SELECT DeptID, SUM(SaleAmount)


FROM Sales
WHERE SaleNumber = 8872
GROUP BY DeptID
HAVING SUM(SaleAmount) > 1000

5.0 Actual Procedure Followed


1. Designed plans through which we can get ideology of executing queries.
2. Created two tables using DML commands.
3. Inserted values into those two tables.
4. Displayed the tables with their records with SELECT command.
5. Executed queries by using WHERE and HAVING clause with the help of SELECT
command to tackle and get output according to the conditions.
6. Tested the queries 4-5 times before the final confirmation.
7. Attached the output of project at the end.
8. Finalized report.

DATABASE MANAGEMENT SYSTEM (22319) Page 5


Annexure II

6.0 Resources Required

Sr. Name of Specifications Qty. Remarks


No. Resource/material
1 Computer 4.00 GB RAM with 32 1
bit OS windows 7 -
2 Software Oracle 11g SQL 1
-
3 Printer HP Deskjet P2 6200
printer 1 -
7.0 Skill Developed / learning out of this Micro-Project
The project can be used in many aspects where there is a need of the database to store
the records of specific things be it a school, university or office. It can also be used in storing
data of any sport player, game’s statistics and many other things. Secondly the queries can be
used to learn DBMS more clearly and its various features.

8.0 Outputs of the Micro-Projects


QUERY:

 Creating two tables : EMPLOYEE and DEPARTMENT

a. create table EMPLOYEE


(emp_name varchar(15), emp_id number(3), salary number(7));
b. create table DEPARTMENT
(dept_name varchar(15),dept_id number(3), emp_id number(3), location varchar(15));

 Inserting values or records in two tables


a. Inserting for EMPLOYEE :

insert into EMPLOYEE values('Rohan', 101, 85000);


insert into EMPLOYEE values('Suyash', 102, 65000);
insert into EMPLOYEE values('Abhishek', 103, 50000);
insert into EMPLOYEE values('Om', 104, 37000);
insert into EMPLOYEE values('Ram', 105, 85000);

b. Inserting for DEPARTMENT :

insert into DEPARTMENT values('Management', 101,101, 'Thane');


insert into DEPARTMENT values('Marketing', 102,102, 'Badlapur');
insert into DEPARTMENT values('Distribution', 103,103, 'Ghatkopar');
insert into DEPARTMENT values('Distribution', 103, 104, 'Dadar');
insert into DEPARTMENT values('Marketing', 102,105, 'Kalyan');

DATABASE MANAGEMENT SYSTEM (22319) Page 6


Annexure II

 Displaying the table with its attributes and records


a. Displaying EMPLOYEE:
Select * from EMPLOYEE;

b. Displaying DEPARTMENT:
Select * from DEPARTMENT;
 Executing QUERIES using WHERE and HAVING CLAUSE

select dept_id, emp_name, salary, location

from DEPARTMENT d, EMPLOYEE e


where d.emp_id = e.emp_id
group by dept_id, emp_name, salary, location
having salary >= 50000
order by dept_id;

DATABASE MANAGEMENT SYSTEM (22319) Page 7


Annexure II

2. Abhishek Chaudhari - 42
3. Suyash Nangare - 43

Name of Team Members with Roll No.

1.Om Ghugare (30)


2.Abhishek Chaudhari (31)
3.Suyash Nangare (32)
4.Rohan Khachane (33)

DATABASE MANAGEMENT SYSTEM (22319) Page 8

You might also like