0% found this document useful (0 votes)
18 views18 pages

DBMS File

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views18 pages

DBMS File

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

PROGRAM NO.

Objective:
a. Introduction to DBMS, RDBMS, DBMS Vs RDBMS
b. Introduction to SQL ,Types of SQL Statements (DDL, DML, TCL,DCL)
c. Introduction to various RDBMS software
d. Oracle Installation, Oracle Live
a) Introduction to DBMS, RDBMS, DBMS Vs RDBMS
Database Management System (DBMS): is a software for storing and
retrieving user’s data while considering appropriate security measures.
Ex: Oracle, MS SQL, MongoDB, MySQL etc.
Relational Database Management System (RDBMS): A database
management system that manages data as a collection of tables in which
all relationships are represented by common values in related tables.

DBMS Vs RDBMS:
b) Introduction to SQL , Types of SQL Statements (DDL, DML,
TCL,DCL)
SQL (Structured Query Language): It is used to perform
operations on the records stored in the database such as updating records,
deleting records, creating, and modifying tables, views, etc.
Types of SQL Statements:
c) Introduction to various RDBMS software

d) Oracle Installation:
Step 1: Go to the Oracle website at http://www.oracle.com.
Step 2: Click on Downloads, and then under Database, click on Oracle Database 11g
Express Edition.
Step 3: Accept the license agreement and select the download version you are
interested in for example, you can download the Oracle Database 11g Release 2
Express Edition for Windows 64 database. The OracleXE112_Win64.zip file is
downloaded.
Step 4: Unzip the .zip file by right-clicking on the file and selecting Extract All..., then
click Extract on the next window. You will now see a DISK1 folder, and inside it is
the setup.exe executable file.
Step 5: Double-click on setup.exe to start the Oracle database installation.
Step 6: On the Welcome to Install Wizard window, click Next.
Step 7: Accept the terms in the license agreement, and click Next.
Step 8: Enter a password, and click Next. This is the password to the SYSTEM
account and you can use any password you wish just note it down.
Step 9: Continue the next windows, click Install to install the database, and
click Finish once installation is complete.
After installation How to use Oracle11g:

Step1: Double click on Oracle11g Express Edition icon


Step2: Login with username system and password oracle
Step3: Click on Application Express and create the workspace

Step4: Login to workspace

Step5: Click on SQL Workshop

Step6: Click on SQL commands

Step7: Write queries


PROGRAM NO.2

Objective: Creating Entity-Relationship Diagram using case tools.

CASE STUDY: College Management System in a College, there are


several departments, and each department has one head of the department
(HOD). Department has a name, its location, and students that belong to
the department. A student can belong to only one department, and a
department can have many students. If a department has recently come
into existence, it might not have any students. Students have roll number,
name, date of birth, gender, hobby, phone number, and address. Faculty
has a name, designation, date of joining, gender & salary and belongs to a
particular department. A department can run many courses with assigned
credits, and students can study any number of courses being offered by
various departments. There are sections within each department, and each
section has many students. Each section has its name, maximum capacity
of that section, and the number of students in that section. Students need
to do one mini-project individually. Each available mini-project has to be
chosen based on its name, domain, subject, and description. Faculty
members can teach multiple courses in multiple departments. One course
can be taught by many faculty members across departments. Faculty
members can be part of multiple research projects. These projects are
either sponsored by the government, industry, or the college itself. The
faculty member can do one or more projects, and one project can have
more than one faculty member. Research projects have a fixed duration,
and their status needs to be tracked regularly.

Entity-Relationship Diagram: The entity-relationship (ER) data model


is based on a perception of a real-world that consists of a collection of
basic objects, called entities, and of relationships among these objects.
Entities are described by a set of attributes.
ER-Diagram:
PROGRAM NO. 3

Objective: DDL Commands: CREATE, ALTER, DROP, TRUNCATE,


CREATING A TABLE From a Table Using SELECT Command

• CREATE: This DDL command is used to create any database with its different objects
such as tables, indexes, triggers, views, stored procedures, built-in functions etc.

• ALTER Statement: Oracle ALTER statement is used when you want to change the
name of your table or any table field. It is also used to add or delete an existing
column in a table. The ALTER statement is always used with "ADD", "DROP" and
"MODIFY" commands according to the situation.

• TRUNCATE statement: The TRUNCATE statement in MySQL removes the


complete data without removing its structure. It is a part of DDL or data definition
language command. Generally, we use this command when we want to delete an
entire data from a table without removing the table structure.

• DROP Table: is used to remove data from the table with schema.
PROGRAM NO. 4

Objective: DML Commands like INSERT, DELETE


and UPDATE
• INSERT- INSERT is most important data manipulation command in
Structured Query Language, which allows users to insert data in
database tables.

• DELETE- This command allows user to delete data in database tables.

• UPDATE: This command allows user to update data in database tables.


PROGRAM NO. 5

Objective: Data Constraints at Column Level and Table level:


PRIMARY Key, FOREIGN Key, UNIQUE, NOT NULL, CHECK,
DEFAULT value concept, Defining and Dropping Constraints using
ALTER Table Command, Assigning User defined names to constraints

• Define constraints while creating a table.

• Defining and Dropping Constraints using ALTER Table


Command
• Assigning User defined names to constraints
PROGRAM NO. 6

Objective: DML Commands: Retrieving database using


SELECT command, Order by clause
• Selecting All Columns of Dept table

• Display department name and location.

• Display name of employees whose name start with S.

• Order by clause
PROGRAM NO.7

Objective: SQL Functions: Date functions, Conversion


functions

• Conversion functions: Convert a value from one data type to another


1. TO_CHAR(date, 'format_model') – Converts Date to String in the
format specified
2. TO_CHAR(number, 'format_model') - Convert numbers to the
character data type using format specified
3. TO_NUMBER(char,[fmt]) - Converts a character string containing
digits to a number in the format specified
4. TO_DATE(char,[fmt]) - Converts a character string representing a
date to a date value according to the fmt that is specified. If fmt is
omitted, the format is DD-MON-YY.
SQL QUERY:

• Date functions: Operate on values of the DATE data type

SQL QUERY :
SELECT ROLLNO, FIRST_NAME || ' ' || LAST_NAME NAME,
DATE_OF_BIRTH, TRUNC(MONTHS_BETWEEN(SYSDATE,
DATE_OF_BIRTH) / 12) || ' YRS' AGE FROM STUDENTS
PROGRAM NO.8

Objective: SQL Functions: Aggregate functions, Single row


functions
1. Aggregate Functions
Aggregate functions operate on multiple rows of data and return a single
summarized value. They are often used with the GROUP BY clause.

SQL QUERY:
SELECT department_id, AVG(salary) AS avg_salary, COUNT(*) AS
total_employees
FROM employees
GROUP BY department_id;

2. Single-Row Functions
Single-row functions operate on each row independently and return one result
per row. They can modify data, format strings, and perform calculations.

SQL QUERY:
SELECT UPPER(employee_name) AS name_uppercase, ROUND
(salary, 2) AS rounded_salary, MONTH(hire_date) AS hiring_month
FROM employees;
PROGRAM NO. 9

Objective: Retrieving information from database using Group


by and Having clause
• Using the GROUP BY Clause
All columns in the SELECT list that are not in group functions must be in
the GROUP BY clause.
Display department number and average salary department wise.

• Using the HAVING Clause


Display department id and maximum salary of those employees where
maximum salary more than 2000 department wise
PROGRAM NO. 10

Objective: Retrieving data using Sub queries


Single row, Multiple rows, ANY operator, ALL operator, EXIST,
Scalar,Multiple columns, Nested, Correlated

Subqueries are queries nested inside another SQL query.


They are used to perform operations in a step-by step
manner and retrieve data based on conditions from
multiple queries.
1. Single Row Subquery: A subquery that returns a single row as a
result.
Select * from Products Where ProductID = (Select
MAX(ProductID) from OrderDetails where OrderID =10250)

2. Multiple Rows Subquery: A subquery that returns more than one


row.
Select * from Products Where ProductID IN (Select ProductID
from OrderDetails where OrderID =10250)

3. ANY Operator: Compares a value to any value returned by the


subquery.
SELECT column1 FROM table1 WHERE column2 > ANY
(SELECT column3 FROM table2 WHERE condition);
4. ALL Operator: Compares a value to all values returned by the
subquery.
SELECT column1 FROM table1 WHERE column2 < ALL
(SELECT column3 FROM table2 WHERE condition);
5. EXISTS: Returns true if the subquery returns one or more rows.
SELECT column1 FROM table1 WHERE EXISTS (SELECT 1
FROM table2 WHERE condition);
6. Scalar Subquery: A subquery that returns exactly one value (one row,
one column).
Select ProductID, ProductName,CategoryID,Price, (Select
Sum(Quantity) from OrderDetails O where
O.ProductID=P.ProductID) As OrderValue from Products P
where CategoryID=2

7. Multiple Column Subquery: A subquery that returns multiple


columns.
SELECT column1 FROM table1 WHERE (column2, column3) =
(SELECT column4, column5 FROM table2 WHERE condition);
8. Nested Subqueries: Subqueries inside other subqueries
Select * from Products Where ProductID IN (Select ProductID
from OrderDetails where Quantity > (Select Quantity from
OrderDetails where OrderDetailID=10))

9. Correlated Subqueries: A subquery that references columns from the


outer query.
SELECT column1 FROM table1 WHERE EXISTS (SELECT 1
FROM table2 WHERE table2.column2 = table1.column3)

You might also like