0% found this document useful (0 votes)
12 views64 pages

Finaldbmsmanual2-240516070243-6d8ac4b6 (1) - Removed

The document outlines the syllabus for a Database Management Systems laboratory course, detailing objectives such as learning SQL commands, nested queries, and database application design. It includes a list of exercises focused on practical skills like creating tables, implementing constraints, and developing GUI applications. Additionally, it provides a structure for experiments and viva questions to assess understanding of key concepts in database management.

Uploaded by

jothimala1507
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)
12 views64 pages

Finaldbmsmanual2-240516070243-6d8ac4b6 (1) - Removed

The document outlines the syllabus for a Database Management Systems laboratory course, detailing objectives such as learning SQL commands, nested queries, and database application design. It includes a list of exercises focused on practical skills like creating tables, implementing constraints, and developing GUI applications. Additionally, it provides a structure for experiments and viva questions to assess understanding of key concepts in database management.

Uploaded by

jothimala1507
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/ 64

SYLLABUS

CS3481 DATABASE MANAGEMENT SYSTEMS LABORATORY LTPC

0 0 3 1.5

COURSE OBJECTIVES:
 To learn and implement important commands in SQL.
 To learn the usage of nested and joint queries.
 To understand functions, procedures and procedural extensions of databases.
 To understand design and implementation of typical database applications.
 To be familiar with the use of a front-end tool for GUI based application development.

LIST OF EXERCISES:
1. Create a database table, add constraints (primary key, unique, check, Not null), insert rows, update and
delete rows using SQL DDL and DML commands.
2. Create a set of tables, add foreign key constraints and incorporate referential integrity.
3. Query the database tables using different ‘where’ clause conditions and also implement aggregate
functions.
4. Query the database tables and explore sub queries and simple join operations.
5. Query the database tables and explore natural, equi and outer joins.
6. Write user defined functions and stored procedures in SQL.
7. Execute complex transactions and realize DCL and TCL commands.
8. Write SQL Triggers for insert, delete, and update operations in a database table.
9. Create View and index for database tables with a large number of records.
10. Create an XML database and validate it using XML schema.
11. Create Document, column and graph based data using NOSQL database tools.
12. Develop a simple GUI based database application and incorporate all the above-mentioned features
13. Case Study using any of the real life database applications from the following list
a) Inventory Management for a EMart Grocery Shop
b) Society Financial Management
c) Cop Friendly App – Eseva
d) Property Management – eMall
e) Star Small and Medium Banking and Finance
● Build Entity Model diagram. The diagram should align with the business and functional goals stated in
the application. 42
● Apply Normalization rules in designing the tables in scope.
● Prepared applicable views, triggers (for auditing purposes), functions for enabling enterprise grade
features.
● Build PL SQL / Stored Procedures for Complex Functionalities, ex EOD Batch Processing for
calculating the EMI for Gold Loan for each eligible Customer.
● Ability to showcase ACID Properties with sample queries with appropriate settings
TOTAL: 45 PERIODS

R2021 / CSBS /CS3481 – DATABASE MANAGEMENT SYSTEMS LABORATORY/ II YEAR / IV SEM / 11


LIST OF EXPERIMENTS – CO MAPPING

S.No TITLE OF THE PROGRAM CO’S

1. DDL AND DML COMMANDS CO1

2. FOREIGN KEY CONSTRAINT CO1


WHERE CLAUSE AND AGGREGATE
3. CO2
FUNCTIONS
4. SUB QUERIES AND SIMPLE JOIN CO2

5. NATURAL, EQUI, OUTER JOIN CO2

6. FUNCTIONS AND STORED PROCEDURES CO3


7.
DCL AND TCL COMMANDS CO2

8. TRIGGERS CO3

9. VIEW AND INDEX CO4

10. XML DATABSE AND XML SCHEMA CO4

11. NOSQL DATABASE CO5

12. GUI APPLICATION CO5

13. REAL LIFE APPLICATION CO5

R2021 / CSBS /CS3481 – DATABASE MANAGEMENT SYSTEMS LABORATORY/ II YEAR / IV SEM / 12


INDEX
Exp. Page Faculty
Date Experiment Marks
No. No. Signature

1. DDL AND DML COMMANDS

2. FOREIGN KEY CONSTRAINT

WHERE CLAUSE AND


3.
AGGREGATE FUNCTIONS

4. SUB QUERIES AND SIMPLE JOIN

5. NATURAL, EQUI, OUTER JOIN

FUNCTIONS AND STORED


6.
PROCEDURES

7. DCL AND TCL COMMANDS

8. TRIGGERS

9. VIEW AND INDEX

XML DATABSE AND XML


10.
SCHEMA

11. NOSQL DATABASE

12. GUI APPLICATION

13. REAL LIFE APPLICATION

R2021 / CSBS /CS3481 – DATABASE MANAGEMENT SYSTEMS LABORATORY/ II YEAR / IV SEM / 13


EX.NO:1a DATA DEFINITION COMMANDS
DATE:

AIM:
To implement database creation and do the operations in database using Data Definition
Commands

ALGORITHM:
Step 1: Create table by using create table command with column name, data type and size.
Step 2: Display the table by using desc command.
Step 3: Add any new column with the existing table by alter table command.
Step 4: Modify the existing table with modify command.
Step 5: Delete the records in files by truncate command.
Step 6: Delete the Entire table by drop command.

1) CREATE TABLE

Syntax:

create table table_name( column1 datatype, column2 datatype, column3 datatype,


..... columnN datatype);

Example:

create table employee(id int,name varchar(100),age int,address varchar(100),salary float);

Table employee created

2) DESCRIBING THE TABLE

Syntax:
desc table_name;

Example:
desc employee;

3) ALTER TABLE

Syntax:
alter table table_name add column_name datatype;

Example:
alter table employee add dept varchar(10);
table employee altered

select * from employee;

Example:
alter table employee add (state varchar(100),weight float);
table employee altered.

select * from employee;

table employee altered.

4) RENAME
To rename column name
Syntax:
alter table table_name rename column existing _name to new_name;

Example:
alter table employee rename column address to addr;
table employee altered.

select * from employee

To rename table name


Syntax:
alter table table_name rename to new_table_name;

Example:
alter table employee rename to empl;
table employee altered.

select * from employee;


ORA-00942: table or view does not exist
00942. 00000 - "table or view does not exist"
*Cause:
*Action:
Error at Line: 21 Column: 15
select * from empl;

5) TRUNCATE

Syntax:
truncate table table_name;

Example:
truncate table emp;
select * from empl;

no data found

6) DROP TABLE

Syntax:
drop table table_name;

Example:

drop table empl;


table customers dropped.

select * from empl;


ORA-00942: table or view does not exist

RESULT:
Thus the queries to implement data definition commands are executed successfully.
EX.NO:1b DATA MANIPULATION COMMANDS
DATE:

AIM:
To implement and execute a query for manipulating & storing data items in a Oracle
database using Structured Query Language commands

ALGORITHM:
Step 1: Create table by using create table command.
Step 2: Insert values into the table
Step 3: Delete any records from the table
Step 4: Update any values in the table.
Step 5: Display the values from the table by using select command.

1) CREATE A TABLE

create table student(id int,Name varchar(30),Department varchar(10));

desc student;

2) INSERT
Syntax:
insert into table_name values(column1,column2,….);
Example:
insert into student values(1,'ABC','CSE');
insert into student values(2,'DEF','CSE');
select * from student;

To insert NULL values to column:


The following syntax is used to insert NULL value to the column.

insert into student values(3,'null','CSE');


select * from student;
To insert default value to the column:
The following syntax is used to insert default value to the table.
Syntax:
insert into table_name values(column1,column2,…);

Example:
insert into student values(3,’alex’,default);
1 rows inserted.
select * from student;

To insert data using select statement:


The following syntax is used insert all the values from another table using select statement.
Syntax:
insert into table_name1 select * from table_name2;

Example:
create table stud(id int,Name varchar(30),Department varchar(10));
insert into stud select * from student;

3) UPDATE
Syntax:
update table_name set column1 = value1, column2 = value2. .. , columnn = valuen
where [condition];
Example: (single column)

update stud set Department='ECE' where id=3;


1 rows updated.
Example: (multiple column)

update stud set Name=’XYZ’,Department='CIVIL' where id=2;

4) DELETE

Syntax: (delete particular row)


delete from table_name where condition;

Example:
delete from stud where id=2;

Syntax:
delete from table_name;

Example:
delete from stud;
select * from stud;

no data found

RESULT:
Thus, a query for manipulating & storing data items in an Oracle database using
Structured Query Language commands were implemented and executed successfully.
EXPERIMENT – 1
VIVA QUESTIONS
1. What is DBMS?
Database Management Systems (DBMS) are applications designed especially which
enable user interaction with other applications.
2. What is DDL?
DDL is Data Definition Language which is used to define the database and schema
structure by using some set of SQL Queries like CREATE, ALTER, TRUNCATE,
DROP and RENAME.
3. What is DML?
DML is Data Manipulation Language which is used to do some manipulations in the
database like Insertion, Deletion, etc. by using some set of SQL Queries like SELECT,
INSERT, DELETE and UPDATE.
4. What is purpose of SQL?
SQL stands for Structured Query Language whose main purpose is to interact with the
relational databases in the form of inserting and updating/modifying the data in the
database
5. What is Primary Key & Unique Key?
The main difference between the Primary key and Unique key is that the Primary key
can never have a null value while the Unique key may consist of null value.
6. Write a query to Create a table?
CREATE TABLE table_name( column1 datatype,
column2 datatype, column3 datatype, );
7. What is foreign key?
Foreign Key is mainly used to link two or more tables together, as this is a particular
field(s) in one of the database tables which are the primary key of some other table.
8. What are the various kinds of interactions catered by DBMS?
The various kind of interactions catered by DBMS are:
 Data definition
 Update
 Retrieval
 Administration
9. What is SQL?
Structured Query Language (SQL) being ANSI standard language updates database and
commands for accessing
10. Enlist the various relationships of database?
The various relationships of database are:
 One-to-one: Single table having drawn relationship with another table
having similar kind of columns.
 One-to-many: Two tables having primary and foreign key relation.
 Many-to-many: Junction table having many tables related to many tables.
EX.NO:2 CREATE SET OF TABLES ADD FOREIGN KEY CONSTRAINT AND
DATE: INCORPORATE REFERENTIAL INTEGRITY

Aim:
To create set of tables add foreign key constraint and incorporate referential integrity using SQL.
Algorithm:
 Create two tables with a link that will not work.
 Create two tables with a link that will work.
 Add a foreign key to enforce referential integrity between the two tables.
 Delete data from the tables.
 Update and remove data to show how the foreign key protects the data.
 Use the cascade option of the foreign key.
 Companies table: List of Companies
 Employees table: List of Employees working at the Company
 Rule: Employees can only work at one Company, and a Company can employ multiple
Employees

Program:
Step 1:
--Create the HRDatabase
USE master
GO
DROP DATABASE IF EXISTS HRDatabase
GO
CREATE DATABASE HRDatabase
GO
USE HRDatabase
GO
Step 2:
-1st Try: Create a Companies and an Employees table and link them together
DROP TABLE IF EXISTS Companies;
GO
DROP TABLE IF EXISTS Employees;
GO
-- SQL CREATE TABLE Statement
CREATE TABLE Companies (
ID INT CONSTRAINT PK_Companies PRIMARY KEY IDENTITY,
CompanyName VARCHAR(80) NOT NULL, -- column name, data types and null value
CompAddress VARCHAR(80) NOT NULL,
CompContactNo VARCHAR(20) NOT NULL,
EmpID INT NOT NULL,
CreateDate DATETIME NOT NULL constraint DF_Companies_CreateDate DEFAULT
getdate()
) CREATE TABLE Employees (
ID INT CONSTRAINT PK_Employees PRIMARY KEY IDENTITY,
EmployeeName VARCHAR(80) NOT NULL,
ContactNo VARCHAR(20) NOT NULL,
Email VARCHAR(80) NOT NULL,
CreateDate DATETIME NOT NULL constraint DF_Employees_CreateDate DEFAULT
getdate()
)
INSERT INTO Companies (CompanyName, CompAddress, CompContactNo, EmpID)
VALUES
('Alpha Company', '123 North Street, Garsfontein, Pretoria', '091 523 6987' , 1),
('Bravo Company', '456 South Street, Brooklyn, Pretoria', '091 523 4789' , 1),
('Charlie Company' , '987 West Street, Lynnwood, Pretoria', '091 523 1235' , 1),
('Delta Company', '258 East Street, The Meadows, Pretoria', '091 523 7414' , 1),
('Echo Company', '100 Amber Street, Hatfield, Pretoria', '091 523 9685' , 1)
INSERT INTO Employees (EmployeeName, ContactNo, Email) VALUES
('Joe Blogs' , '012 365 4789', 'joeblogs@gmail.com') ,
('Jane Doe' , '012 365 4789', 'janedoe@gmail.com') ,
('John Smit' , '012 365 4789', 'johnsmit@gmail.com') ,
('Eddy Jones' , '012 365 4789', 'eddyjones@gmail.com'),
('Steve Dobson', '012 365 4789', 'stevedobson@gmail.com')

SELECT * FROM Companies


SELECT * FROM Employees

OUTPUT :
3

RESULT:
Thus, to create a set of tables add foreign key constraint and incorporate referential integrity were
implemented and executed successfully.
EXPERIMENT – 2
VIVA QUESTIONS

1. Define Aggregate functions?


Functions which operate against a collection of values and returning single value is called
aggregate functions
2. Define Scalar functions?
Scalar function is depended on the argument given and returns sole value.
3. Why WHERE clause is used?
The WHERE clause is used to filter records.
It is used to extract only those records that fulfill a specified condition. Syntax
SELECT column1, column2, ... FROM table_name
WHERE condition.
4. What is ACID Properties?
A-Atomicity
C-Consistency I-Isolation
5. Different types of abstraction levels?
There are 3 levels of data abstraction in the DBMS.
Physical level
Logical level
View level
6. What is the concept of sub-query in terms of SQL?
Sub-query is basically the query which is included inside some other query and can also
be called as an inner query which is found inside the outer query
7. What is Correlated Subquery in DBMS?
A Subquery is also known as a nested query i.e. a query written inside some query. When
a Subquery is executed for each of the rows of the outer query then it is termed as a
Correlated Subquery.
8. What is a join in the SQL?
A Join is one of the SQL statements which is used to join the data or the rows from 2 or
more tables on the basis of a common field/column among them.
9. What is simple join?
Join is used to display matching records from both tables. This is also called a simple if
you omit inner the keyword and just use join, this is the type of join you’ll get by default.
10. What are the 4 types of joins in SQL?
a. Inner join
b. Right join
c. Left join
d. Full join
EX.NO:3 DATABASE TABLES WITH DIFFERENT 'WHERE CLAUSE' CONDITIONS
DATE:

Aim:
To using query the database tables with different 'where clause' conditions also implement
aggregate function with algorithm

Algorithm:
Step 1:
There are tables country and city. We’ll use the following statements:

SELECT *
FROM country;
SELECT *
FROM city;
You can see the result in the picture below:
Step 2:
SELECT *
FROM country
INNER JOIN city ON city.country_id = country.id;

SELECT COUNT(*) AS number_of_rows


FROM country
INNER JOIN city ON city.country_id = country.id;

Step 3:

SELECT *FROM country


LEFT JOIN city ON city.country_id = country.id;

SELECT COUNT(*) AS number_of_rows


FROM country
LEFT JOIN city ON city.country_id = country.id;

SELECT COUNT(country.country_name) AS countries, COUNT(city.city_name) AS cities


FROM country
LEFT JOIN city ON city.country_id = country.id;

RESULT:
Thus the SQL query the database tables with different 'where clause' conditions also
implement aggregate function are executed successfully.
EXPERIMENT – 3
VIVA QUESTIONS

1. How do you retrieve data from a table based on a specific condition?


You can use the SELECT statement with the WHERE clause.
2. Explain how you can combine multiple conditions in a WHERE clause.
You can use the AND and OR operators to combine conditions.
3. How do you filter data based on multiple possible values?
You can use the IN operator for this purpose.
4. How can you retrieve data within a specific range?
The BETWEEN operator is used for this.
5. How do you perform a partial string match in a WHERE clause?
The LIKE operator is used, along with wildcards (% for any characters, _ for a single
character).
6. How do you filter records based on the presence or absence of NULL values?
You can use the IS NULL or IS NOT NULL conditions
7. Can you retrieve data with a specific condition and have it ordered in a particular way?
Yes, you can combine WHERE with ORDER BY.
8. How do you handle complex conditions in a WHERE clause?
You can use parentheses to group conditions and control the logic.
9. What is natural joins?
A NATURAL JOIN is a JOIN operation that creates an implicit join clause for you
based on the common columns in the two tables being joined. Common columns are
columns that have the same name in both tables.
10. What is equi in sql?
The EQUI JOIN in SQL performs a JOIN against a column of equality or the matching
column(s) values that have the associated tables. Here, we use an equal sign (=) as a
comparison operator in our ‘where’ clause to refer to equality.
EX.NO:4 SIMPLE QUERIES, SUB QUERIES, JOINS
DATE:

AIM:
To implement Simple queries, Nested queries, Sub queries using structured query
language

ALGORITHM:

STEP 1: Create a table with the columns that are needed


STEP 2: Write simple queries to insert, delete, update and implement some functions
STEP 3: Write nested queries using clauses to retrieve data from the table
STEP 4: The nested queries may have more than one sub queries.
STEP 5: Efficiently retrieve data from the table

QUERIES:
create table salary(id int, Name varchar(20),Age int,Salary float);
insert into salary values(1,'Ajay',25,20000);
insert into salary values(2,'Archana',28,30000);
insert into salary values(3,'Archana',23,25000);
insert into salary values(4,'Sara',24,20000);
insert into salary values(5,'Ajay',25,40000);
insert into salary values(6,'Srinithi',26,35000);
select * from salary;

Sum function
Syntax:
select column_name1,sum(column_name2)from table_name group by column_name3;

Example:
select name, sum(salary) from salary group by name;

Min function

Syntax:
select column_name1,min(column_name2)from table_name group by column_name3;

Example:
select name, min(salary) from salary group by name;
Max function
Syntax:
select column_name1,max(column_name2)from table_name group by column_name3;
Example:
select name, max(salary) from salary group by name;

Count function

Syntax:
select column_name1,count(column_name2)from table_name group by column_name3;
Example:
select name, count(salary) from salary group by name;

Mod function

Syntax:
select column_name1,mod(column_name2)from table_name;
Example:
select name,mod(salary,5) from salary;

DISTINCT and ORDER BY Clause

Syntax:
select distinct column1, column2,. ... columnn from table_name;

Example:
select salary from salary order by salary;
select distinct salary from salary order by salary;

HAVING clause
Example:

select min(salary)from salary group by age having max(salary)<30000;

Select using Conditions

AND
Example:
select * from salary where age >= 25 and salary >= 25000;

OR
Example:
select * from salary where age >= 25 or salary >= 25000;

LIKE
select * from salary where name like 'Aj%';
IN
select * from salary where age in ( 25, 28 );

BETWEEN
select * from salary where salary between 20000 and 30000;

IS NOT NULL

select * from salary where age is not null;

IS NULL

select * from salary where age is null;


no data found

(4,'Kumaran',25,'CBE',24000);

Subqueries with theINSERT Statement

INSERT INTO customers_backup


SELECT * FROM CUSTOMERS
WHERE ID IN
(SELECT ID
FROM CUSTOMERS) ;
4 rows inserted

select * from customers_backup;

Subqueries with the UPDATE Statement

UPDATE CUSTOMERS
SET SALARY = SALARY * 0.25
WHERE AGE IN
(SELECT AGE FROM customers_backup
WHERE AGE >= 27 );
Select * from customers;
Subqueries with the DELETE Statement

DELETE FROM CUSTOMERS


WHERE AGE IN
(SELECT AGE FROM CUSTOMERS_backup
WHERE AGE >= 27 );

select * from customers;


select age from customers where exists (select age from salary where salary > 25000);

JOINS

CREATE and INSERT values in TABLE(cust)

create table cust(id int primary key,name varchar(20),age int);


insert into cust values(1,'aaa',32);
insert into cust values(2,'aba',32);
insert into cust values(3,'abc',32);
insert into cust values(4,'ccc',25);
select * from cust;

CREATE and INSERT values in TABLE(order1)

create table order1(oid int primary key,custid int,amount int);


insert into order1 values(101,1,1000);
insert into order1 values(102,2,2000);
insert into order1 values(103,3,3000);

1. INNER JOIN

Syntax:
SELECT table1.column1, table2.column2...
FROM table1
INNER JOIN table2
ON table1.common_filed = table2.common_field;

Example:

select id,name,oid,amount
from cust
inner join order1
on cust.id=order1.custid;

2. LEFT JOIN:
Syntax:

select table1.column1, table2.column2...


from table1
left join table2
on table1.common_filed = table2.common_field;

Example:
select id,name,oid,amount
from cust
left join order1
on cust.id=order1.custid;

3. RIGHT JOIN:
Syntax:
select table1.column1, table2.column2...
from table1
right join table2
on table1.common_filed = table2.common_field;

Example:
select id,name,oid,amount
from cust
right join order1
on cust.id=order1.custid;
4. FULL JOIN:
Syntax:

select table1.column1, table2.column2...


from table1
full join table2
on table1.common_filed = table2.common_field;

Example:
select id,name,oid,amount
from cust
full join order1
on cust.id=order1.custid;

RESULT:
Thus the SQL commands to execute simple queries, sub queries and joins areexecuted
successfully.
EXPERIMENT – 4
VIVA QUESTIONS

1. What is a sub query, and how is it different from a regular query?


A sub query is a query nested inside another query. It can be used within a WHERE
clause to retrieve data that will be used by the main query.
2. Provide an example of a correlated sub query.
A correlated sub query references a column from the outer query.
Example: SELECT employee_name FROM employees WHERE salary > (SELECT
AVG(salary) FROM employees WHERE department_id =
employees.department_id);
3. When would you use a sub query instead of a JOIN?
Sub queries are useful when you need to retrieve a single value or a set of values that
can be used by the main query, while Joins are used to combine columns from two or
more tables.
4. Explain the difference between INNER JOIN and LEFT JOIN.
INNER JOIN returns only the matching rows between two tables, while LEFT JOIN
returns all rows from the left table and the matching rows from the right table.
5. What is a self-join, and in what scenario would you use it?
A self-join is when a table is joined with itself. It is used when you want to compare
records within the same table, such as finding employees who share the same manager.
6. How do you retrieve columns from multiple tables using a JOIN?
Use the SELECT statement with the appropriate JOIN clause.
For example: SELECT employees.employee_name, departments.department_name
FROM employees INNER JOIN departments ON employees.department_id =
departments.department_id;
7. Explain the purpose of the USING clause in a JOIN.
The USING clause is used to specify a column that exists in both tables and should be
used as the join condition.
For example: SELECT * FROM employees JOIN departments USING
(department_id);
8. . Is SELF JOIN an INNER JOIN or OUTER JOIN?
The SELF JOIN can be an INNER JOIN, OUTER JOIN, or can also be CROSS JOIN.
Tables are automatically linked based on columns that contain duplicate data in
multiple rows.
9. IS required that the JOIN condition be based on equality?
No, because JOINS have the conditions of NON-EQUI. Sentence combinations can
be done with common ssymbols such as <, <=, >, >=, !=, BETWEEN, for example,
to represent data. Odd-pair indexing and identifying duplicate data are several cases
where NON-EQUI JOINS performance can be demonstrated.
10. What is index in sql?
Indexes are used to retrieve data from the database more quickly than otherwise. The
users cannot see the indexes, they are just used to speed up searches/queries
EX.NO:5 NATURAL, EQUI AND OUTER JOIN
DATE:

Aim
To write DQL Commands to join, Restrict and Retrieve information from one or more
tables execute it and verify the same.

Algorithm
Selecting Rows with Equijoin using table Aliases

1. Write a query to display empid,name,deptid,deptname and


location for allemployees and verify it.

SQL> select
employee.empid,employee.name,employee.depid,department.deptname,depa
rtment.location from employee,department where
employee.depid=department.depid;

EMPID NAME DEPID DEPTNAME LOCATION

a123 ragu CS000 COMPUTER_SCIENCE CHENNAI


a124 rama CS000 COMPUTER_SCIENCE CHENNAI
a125 ram EE000 ELECT_ELECTRO MUMBAI
a128 sag EE000 ELECT_ELECTRO MUMBAI
c128 dinesh EC000 ELECT_COMM DELHI
d124 abc EC000 ELECT_COMM DELHI

6 rows selected.

2. Write a query to display the “dinesh” depid and deptname and verify it.
SQL> select e.empid,e.name,e.depid,d.deptname from employee
e,department d wheree.depid=d.depid and e.name='dinesh';

EMPID NAME DEPID DEPTNAME

c128 dinesh EC000 ELECT_COMM

Selecting Rows with Non-Equijoin using table Aliases:


[Other Conditions such as >=, <= and BETWEEN, AND ]

1. Write a query to display the name,salary and deptname of all


employees whose salary is greater than 10000 and verify it.

SQL> select e.name,e.salary,d.deptname from employee e,department d where


e.salary>10000and e.depid=d.depid;

NAME SALARY DEPTNAME

ragu 200000 COMPUTER_SCIENCE


rama 200000 COMPUTER_SCIENCE
ram 30000 ELECT_ELECTRO
Selecting Rows using Outer Joins:[ Left Outerjoin,Right Outerjoin using ”+”
symbol ]

1. Write a query to display the name, depid and deptname of all


employees.Make surethat employees without department are included as
well and verify it.

SQL> select e.name,e.depid,d.deptname from employee e,department d where e.depid


=d.depid(+);

NAME DEPID DEPTNAME

rama CS000 COMPUTER_SCIENCE


ragu CS000 COMPUTER_SCIENCE
sag EE000 ELECT_ELECTRO
ram EE000 ELECT_ELECTRO
abc EC000 ELECT_COMM
dinesh EC000 ELECT_COMM
www

7 rows selected.
2. Write a query to display the name, salary,depid and deptname of
all employees. Make sure that departments without employees are
included as well and verify.
SQL> select e.name,e.salary,e.depid,d.deptname from employee
e,department d where e.depid(+)=d.depid;

NAME SALARY DEPID DEPTNAME

ragu 200000 CS000 COMPUTER_SCIENCE


rama 200000 CS000 COMPUTER_SCIENCE
ram 30000 EE000 ELECT_ELECTRO
sag 10000 EE000 ELECT_ELECTRO
dinesh 10000 EC000 ELECT_COMM
abc 5000 EC000 ELECT_COMM
MECHANICAL
CHEMICAL
8 rows selectedd

RESULT:
Thus the SQL commands to execute natural, equi and outer joins are executed successfully.
EXPERIMENT – 5
VIVA QUESTIONS

1. What is a Database system?


The database and DBMS software together is called as Database system.
2. What are the Advantages of DBMS?
Redundancy is controlled.
Unauthorized access is restricted.
Providing multiple user interfaces.
Enforcing integrity constraints. Providing backup and recover.
3. What is functional dependency in DBMS?
This is basically a constraint which is useful in describing the relationship among
the different attributes in a relation.
4. What is stored procedures?
A stored procedure is a prepared SQL code that you can save, so the code can be
reused over and over again. So if you have an SQL query that you write over and
over again, save it as a stored procedure.
5. What is an entity?
It is a `thing’ in the real world with an independent existence.
6. Can you provide an example of when you would use a Natural Join?
Suppose you have a "Customers" table and an "Orders" table, both having a
"CustomerID" column. A Natural Join could be used to retrieve information about
customers and their corresponding orders without explicitly specifying the join
condition.
7. What is the key characteristic of an Equi Join?
The key characteristic of an Equi Join is that it involves the use of the equality
operator (=) to match rows between two tables based on specified columns.
8. Can you give an example of when you might use an Equi Join in a database query?
Let's say you have a "Students" table and a "Courses" table, both having a
"StudentID" column. An Equi Join could be used to find students who are enrolled
in specific courses by matching the "StudentID" values
9. Explain the concept of an Outer Join.
An Outer Join retrieves matching rows from tables and includes non-matching rows
from one or both tables. It ensures that even if there are no matches, rows from one
or both tables are still included in the result set.
10. Write the syntax for view?
CREATE VIEW view_name AS SELECT columns FROM tables [WHERE
conditions]; view_name.
EX.NO:6 PROCEDURES AND FUNCTIONS
DATE:

AIM:
To implement and execute Procedures in Oracle Database using Procedural Language
concepts.

PROCEDURES:
1) Procedure is a sub program used to perform an action.
2) Replace-recreates the procedure if it already exists.

3 MODES:
1) IN – Means you must specify a value for the argument at the time execution of the procedure.

2) OUT-passes back a value to its calling program.

3) INOUT – When calling the procedure, yu must specify the value and that procedures passes value back
to the calling procedure

CREATING A PROCEDURE

SYNTAX:

CREATE [OR REPLACE] PROCEDURE procedure_name


[(column_name [IN | OUT | IN OUT] type [, ...])]
{IS |
AS}
BEGIN
< procedure_body >
END procedure_name;

CREATE OR REPLACE PROCEDURE greetings


AS
BEGIN
dbms_output.put_line('Hello World!');
END;

To run this procedure

BEGIN
greetings;
END;

DELETING A PROCEDURE

SYNTAX:

DROP PROCEDURE procedure-name;

EXAMPLE:

DROP PROCEDURE greetings;

Procedure dropped
EXAMPLE 2

Create a table user1

create table user1(id number(10) primary key,name varchar2(100));

Create the procedure

create or replace procedure


INSERTUSER(id IN NUMBER, name IN VARCHAR2)
is
begin
insert into user1 values(id,name);
end;

To execute the procedure

BEGIN
INSERTUSER(101,'Rahul');
dbms_output.put_line('record inserted successfully');
END;

PL/SQL FUNCTIONS

SYNTAX:

CREATE [OR REPLACE] FUNCTION function_name [parameters]


[(parameter_name [IN | OUT | IN OUT] type [, ...])]
RETURN return_datatype
{IS | AS}
BEGIN
< function_body >
END [function_name];

create or replace function adder(n1 in number, n2 in number)


return number
is
n3 number(8);
begin
n3 :=n1+n2;
return n3;
end;

EXECUTE THE FUNCTION

DECLARE
n3 number(2);
BEGIN
n3 := adder(11,22);
dbms_output.put_line('Addition is: ' || n3);
END;
Output:

Addition is: 33

Statement processed.

RESULT:
Thus the PL/SQL procedures and functions are executed successfully
EXPERIMENT – 6
VIVA QUESTIONS

1. What is a stored procedure?


A stored procedure is a recompiled collection of one or more SQL statements that
can be stored and executed on a database server. It allows for the reuse of code and
helps improve performance by reducing the need to send multiple SQL statements
over the network.
2. How is a stored procedure different from a regular SQL query?
A stored procedure is a saved set of SQL statements with a name and can accept
parameters. It is recompiled and stored on the server, whereas a regular SQL query
is sent to the server for immediate execution.
3. What are the advantages of using stored procedures?
Stored procedures offer advantages such as code re usability, improved
performance due to recompilation, better security control, and easier maintenance.
4. Can you explain how parameters work in stored procedures?
Parameters in stored procedures act as placeholders for values that can be passed
during the procedure's execution. They allow for flexibility and customization of
the procedure's behavior.
5. How do you call a stored procedure?
A stored procedure is called using the CALL or EXECUTE statement, followed by
the procedure name and any necessary parameters.
6. What is a function in the context of a database?
A function is a recompiled set of SQL statements that performs a specific task and
returns a single value. It is similar to a stored procedure but is designed to return a
value rather than perform an action
7. How is a function different from a stored procedure?
While both functions and stored procedures can contain sets of SQL statements,
functions return a value, while stored procedures do not necessarily return a value
but may perform actions.
8. What are the types of functions commonly used in databases?
Common types of functions include scalar functions (returning a single value),
table-valued functions (returning a table), and aggregate functions (performing a
calculation on a set of values).
9. Can functions have side effects?
Ideally, functions are designed to be deterministic and not have side effects.
However, some database systems allow functions to have side effects, which can
impact the consistency of the database.
10. What is TCL?
TCL is abbreviation of Transaction Control Language. It is used to manage different
transactions occurring within a database.
EX.NO.7 TRANSACTION CONTROL AND DATA CONTROL STATEMENTS
DATE:

AIM:
To implement Transaction Control statements using structured Query Language

ALGORITHM:

Step 1: Create table by using create table command.


Step 2: Insert values into the table
Step 3: Commit the table
Step 4: Insert or Update any values in the table.
Step 5: Rollback the table
Step 6: Insert or Update any values in the table.
Step 7: Fix a save point
Step 8: Repeat step 6 and 7
Step 9: Rollback to any save point

1) CREATE A TABLE

create table employeepersonaldetails(id int primary key,name varchar(30) not null,age int not
null,mobilenumber int not null unique);

insert into employeepersonaldetails values(1,'Ajay',20,9876543210);


insert into employeepersonaldetails values(2,'Brindha',20,9874563210);
insert into employeepersonaldetails values(3,'Kumaran',20,9673443210);
select * from employeepersonaldetails;

commit;

Statement executed

insert into employeepersonaldetails values(4,'Archana',20,9876543410);


rollback;

insert into employeepersonaldetails values(5,'Braham',20,9878953210);

savepoint a;

savepoint created

insert into employeepersonaldetails values(6,'Srimathi',20,9678953210);

savepoint b;

rollback to a;

RESULT:
Thus Transaction Control and Data Control statements using structured Query Language is
executed successfully
EXPERIMENT – 7
VIVA QUESTIONS

1. What is a transaction in a database?


A transaction is a sequence of one or more SQL statements that are executed as a
single unit of work, ensuring that either all the statements are executed successfully,
or none of them are.
2. Explain the concept of a save point.
A save point is a point within a transaction to which you can roll back. It allows for
partial rollback of a transaction in case of errors without rolling back the entire
transaction.
3. Why is it important to use transaction control statements?
Transaction control statements ensure the consistency and integrity of the database
by allowing changes to be either fully applied or fully undone. They help maintain
the reliability of the data.
4. What is the purpose of the GRANT statement?
The GRANT statement is used to give specific privileges to a user or a role,
allowing them to perform certain actions on database objects like tables, views, or
procedures.
5. Explain the concept of database privileges.
Database privileges define the actions that a user or role is allowed to perform on a
specific database object. Examples include SELECT, INSERT, UPDATE,
DELETE, and EXECUTE privileges.
6. How is the REVOKE statement used?
The REVOKE statement is used to revoke previously granted privileges from a user
or role, restricting their access to specific database objects.
7. What is the purpose of the DENY statement?
The DENY statement is used to explicitly deny a user or role specific privileges on
a database object. It takes precedence over any previously granted privileges
8. How do data control statements contribute to database security?
Data control statements help manage access to database objects, ensuring that users
have appropriate permissions to perform necessary actions while restricting
unauthorized access. This contributes to the security and integrity of the database.
9. Examples of DCL?
GRANT: This command gives users access privileges to the database.
REVOKE: This command withdraws the user's access privileges given by using
the GRANT command.
COMMIT: Commits a Transaction.
10. What is the difference between DCL & TCL?
By using DDL commands, database transaction cannot be handled. TCL commands
are meant to handle database transaction
EX.NO:8 TRIGGERS
DATE:

AIM:
To implement PL/SQL triggers and do the operations in database automatically.

ALGORITHM:

STEP1: Create a table emply101


STEP2: Insert values into the table
STEP3: Create another table emply102
STEP4: Create trigger
CREATE OR REPLACE TRIGGER <TRIGGER NAME>
{BEFORE/AFTER/INSTEAD OF}
{INSERT/UPDATE/DELETE}
ON <TABLENAME/VIEWNAME>
REFRENCECING {OLD AS OLD /NEW AS NEW}
[FOR EACH STATEMENT /FOR EACH ROW [WHEN <CONDITION>]]
STEP5: Insert and delete record into emply101
STEP6: View the updations in emply102

CREATE TABLE emply101


create table emply101(eid varchar(20),ename char(25), age number(10), salary number(10));
insert into emply101 values(1,'abi',23,25000);
insert into emply101 values(2,'abinaya',22,20000);
insert into emply101 values(3,'abishek',23,25000);
select * from emply101;

CREATE TABLE emply102


create table emply102(eid varchar(20),ename char(25),age number(10),salary number(10));
select * from emply102;
no data found
Creating trigger
create or replace trigger tfg1 before insert on emply101 for each row
begin
insert into emply102 values(:new.eid,:new.ename,:new.age,:new.salary);
end;
Insert values into emply101

insert into emply101 values(4,'bala',23,25000);


select * from emply101;

select * from emply102;

CREATING TRIGGER FOR UPDATING AND DELETING

create or replace trigger trgrr15 after delete or update on emply101 for each row
begin
if deleting then
insert into emply102 values(:old.eid,:old.ename,:old.age,:old.salary);
elsif updating then
insert into emply102 values(:old.eid,:old.ename,:old.age,:old.salary);
end if;
end;

Update a value in emply101

update emply101 set salary=10000 where eid=1;


select * from emply102;

RESULT:
Thus the SQL triggers are executed successfully.
EXPERIMENT – 8
VIVA QUESTIONS

1. What is a database trigger?


A database trigger is a set of instructions or code that is automatically executed
("triggered") in response to a specific event, such as an INSERT, UPDATE,
DELETE, or another action, occurring in a database.
2. What are the types of triggers commonly used in databases?
The two main types of triggers are BEFORE triggers, which are executed before
the triggering event, and AFTER triggers, which are executed after the triggering
event.
3. How does a BEFORE INSERT trigger differ from an AFTER INSERT trigger?
A BEFORE INSERT trigger is executed before the actual insertion of data into the
table, allowing for validation or modification of data. An trigger is executed after
the data has been inserted, and it can perform actions based on the successful
insertion.
4. What is the purpose of using triggers in a database?
Triggers are used to enforce business rules, ensure data integrity, and automate
actions in response to specific events, reducing the need for manual intervention
and enhancing the consistency of the database.
5. Can a trigger be associated with more than one event?
Yes, a trigger can be associated with multiple events. For example, a trigger can be
designed to execute on both
BEFORE INSERT and BEFORE UPDATE events.
6. How do you create a trigger in a database?
To create a trigger, you use the CREATE TRIGGER statement, specifying the
trigger name, timing (BEFORE or AFTER), event (INSERT, UPDATE, DELETE),
and the SQL statements or procedures to be executed.
7. Explain the concept of a FOR EACH ROW trigger.
A FOR EACH ROW trigger is a type of trigger that is executed once for each row
affected by the triggering event. It is commonly used with row-level actions, such
as validating or modifying data on a per-row basis.
8. How do you disable or drop a trigger?
You can disable a trigger using the
TRIGGER. To drop a trigger, you use the
9. Can triggers cause performance issues in a database?
statement and re-enable it using statement.
Poorly designed triggers or triggers with complex logic can potentially cause
performance issues. It's essential to carefully design triggers to ensure they do not
adversely impact database performance
10. Provide an example scenario where a trigger might be useful.
A trigger could be useful in enforcing a rule that prevents the deletion of records
from a critical table, ensuring that a record can only be marked as inactive
(UPDATE instead of DELETE).
EX.NO:9 VIEWS AND INDEX
DATE:

AIM:

To write a DDL command to create views to restrict data access from one or more tables, execute
it and verify the same.

Creating views:

1. Create a view that contains employee id as “ID_NUMBER”, employee name


as “NAME”and salary as ”SALARY” for each employee in department 90.

SQL> create view vw_emp80(id,name,salary) as select empid,name,salary from


employee wheredeptid=90;

OUTPUT:

View created.
SQL> select * from vw_emp80;

ID NAME SALARY

s203 vidhya 29000


2. To create a view to set the salary Rs.15000/- to the employee id ‘a102’ in the
vw_dept_salary and verify the result in vw_emp12_sal and employees table.

SQL> update vw_emp12 set salary=15000 where

empid='a102';1 row updated.

To Verify: SQL> select * from vw_emp12;

SNO NAME SALARY DESIG LAST EMPID DEPTID HIRE_DATE

1 monica 15000 rep a a102 102 13-MAR-08


Creating Index
Create table
CREATE TABLE Colleges ( college_id INT PRIMARY KEY,college_code
VARCHAR(20),NOT NULL college_name VARCHAR(50)
);
create index
CREATE INDEX college_index ON Colleges(college_code);
Colleges

college_id college_code college_name


empty

RESULT:
Thus the PL/SQL program for implementing views and index has been successfully executed.
EXPERIMENT – 9
VIVA QUESTIONS

1. What is an index in a database?


An index is a data structure that improves the speed of data retrieval operations on
a database table. It is created on one or more columns of a table to quickly locate
and access rows based on the indexed columns.
2. Why are indexes used, and what benefits do they provide?
indexes are used to improve the speed of data retrieval operations by facilitating
quicker access to rows. They enhance query performance, especially for SELECT
statements, by minimizing the number of rows that need to be scanned.
3. What is the trade-off associated with using indexes?
While indexes improve query performance, they come with the trade-off of
increased storage space and potential overhead during data modification
operations (INSERT, UPDATE, DELETE), as the indexes also need to be
maintained.
4. Can you create an index on multiple columns?
Yes, a composite index, or multi-column index, can be created on multiple
columns. This type of index is useful when queries involve conditions on multiple
columns.
5. How does an index impact the performance of SELECT queries?
Indexes can significantly improve the performance of SELECT queries by
allowing the database engine to quickly locate and retrieve the relevant rows,
reducing the need for full table scans.
6. When would you consider not using an index?
Indexes may not be necessary for small tables or tables with infrequent queries. In
situations where data modifications (INSERT, UPDATE, DELETE) significantly
outweigh read operations, the overhead of maintaining indexes may outweigh the
benefits.
7. Explain the concept of a clustered index.
A clustered index determines the physical order of data in a table. The rows in the
table are stored on disk in the same order as the index, making it different from a
non-clustered index where the order on disk does not match the index order.
8. What is meant by trigger?
Trigger is one of the very important codes or programs which get executed
automatically in response to the events that occur in a table or a view.
9. What are the operations performed in trigger?
10. Syntax for trigger?
CREATE TRIGGER schema.trigger_name
ON table_name
AFTER {INSERT, UPDATE, DELETE}
[NOT FOR REPLICATION]
AS
{SQL_Statements}
EX.NO:10 XML SCHEMA
DATE:

AIM:

To implement XML Database and validate it using XML Schema.

PROGRAM
CREATE TABLE t1 (
id NUMBER,
xml XMLTYPE
);

INSERT INTO t1 VALUES (1, '<?xml version="1.0" encoding="UTF-8"?>


<shiporder orderid="889923">
<orderperson>John Smith</orderperson>
<shipto>
<name>Ola Nordmann</name>
<address>Langgt 23</address>
<city>4000 Stavanger</city>
<country>Norway</country>
</shipto>
<item>
<title>Empire Burlesque</title>
<note>Special Edition</note>
<quantity>1</quantity>
<price>10.90</price>
</item>
<item>
<title>Hide your heart</title>
<quantity>1</quantity>
<price>9.90</price>
</item>
</shiporder>');

INSERT INTO t1 VALUES (2, '<?xml version="1.0" encoding="UTF-8"?>


<shiporder orderid="889923">
<orderperson>John Smith</orderperson>
<shipto>
<name1>Ola Nordmann</name1>
<address>Langgt 23</address>
<city>4000 Stavanger</city>
<country>Norway</country>
</shipto>
<item>
<title>Empire Burlesque</title>
<note>Special Edition</note>
<quantity>1</quantity>
<price>10.90</price>
</item>
<item>
<title>Hide your heart</title>
<quantity>1</quantity>
<price>9.90</price>
</item>
</shiporder>');

COMMIT;

OUTPUT

SELECT id,
XMLISVALID(xml, 'my_schema.xsd') AS is_valid
FROM t1;

ID IS_VALID
------- ----------
1 1
2 0

RESULT:
Thus the XML Database and validate it using XML Schema is executed successfully.
EXPERIMENT – 10
VIVA QUESTIONS

1. What is an XML Schema?


An XML Schema is a way to describe the structure and constraints of XML
documents. It defines the elements, attributes, data types, and the relationships
between them in an XML document.
2. Why is XML Schema important in the context of XML documents?
XML Schema provides a standardized way to define the structure and data types of
XML documents, ensuring consistency and facilitating interoperability between
systems that exchange XML data.
3. What are the key components of an XML Schema?
The key components of an XML Schema include elements, attributes, data types,
complex types, simple types, and the relationships between them.
4. Explain the difference between a complex type and a simple type in XML Schema.
A complex type can contain other elements and attributes, allowing for a more
complex structure. A simple type, on the other hand, represents atomic data types
like strings, numbers, or dates without containing other elements.
5. How do you define an element in an XML Schema?
Elements are defined using the <element> tag in an XML Schema. You specify the
name, type, and any constraints for the element within this tag.
6. What is the purpose of the XML Schema complexType element?
The complexType element is used to define complex types, which can contain other
elements and attributes. It allows for the creation of more structured and hierarchical
data models.
7. How can you restrict the values of an element using XML Schema?
You can use the restriction element to restrict the values of an element based on a
specific data type, such as restricting a string to a certain length or restricting a
number to a specific range.
8. Explain the concept of XML Schema namespaces.
XML Schema namespaces are used to avoid naming conflicts between elements
and types. They allow different XML vocabularies or applications to define
elements and types with the same name without colliding.
9. What is the purpose of the include and import statements in XML Schema?
The include statement is used to include components from another schema file,
while the import statement is used to import components from another schema
namespace.
10. How does XML Schema contribute to data validation in XML documents?
XML Schema provides a set of rules and constraints that define the structure and
data types of XML documents. During document validation, the XML processor
checks whether the document conforms to the specified schema.
EX.NO:11 NOSQL DATABASE TOOLS
DATE

Aim:
To design and develop MongoDB queries using CRUD operations.

Algorithm:

Step 1: Create table by using create table command.


Step 2: Insert values into the table
Step 3: Delete any records from the table
Step 4: Update any values in the table.
Step 5: Display the values from the table by using select command.
Step 6: Search any value using find.

Query:
> db.createCollection('Student');
{ "ok" : 1 }
> db.Student.insert({'Rno':'1','Name':'Piyush','Class':'TE COMP'});
WriteResult({ "nInserted" : 1 })
> db.Student.insert({'Rno':'2','Name':'Abhi','Class':'TE COMP'});
WriteResult({ "nInserted" : 1 })
> db.Student.insert({'Rno':'3','Name':'Ashley','Class':'TE
COMP'});WriteResult({ "nInserted" : 1 })
> db.Student.insert({'Rno':'4','Name':'Hitesh','Class':'TE COMP'});
WriteResult({ "nInserted" : 1 })
> db.Student.insert({'Rno':'5','Name':'Pratik','Class':'TE COMP'});
WriteResult({ "nInserted" : 1 })
> db.Student.insert({'Rno':'6','Name':'Pratik','Class':'TE COMP'});
WriteResult({ "nInserted" : 1 })
> db.Student.find();
{ "_id" : ObjectId("5b8fad4ef00832a0a50b5036"), "Rno" : "1",
"Name" : "Piyush", "Class" : "TE COMP" }
{ "_id" : ObjectId("5b8fad62f00832a0a50b5037"), "Rno" : "2",
"Name" : "Abhi", "Class" : "TE COMP" }
{ "_id" : ObjectId("5b8fad70f00832a0a50b5038"), "Rno" : "3",
"Name" : "Ashley", "Class" : "TE COMP" }
{ "_id" : ObjectId("5b8fad7ff00832a0a50b5039"), "Rno" : "4",
"Name" : "Hitesh", "Class" : "TE COMP" }
{ "_id" : ObjectId("5b8fad8df00832a0a50b503a"), "Rno" : "5",
"Name" : "Pratik", "Class" : "TE COMP" }
{ "_id" : ObjectId("5b8fada4f00832a0a50b503b"), "Rno" : "6",
"Name" : "Pratik", "Class" : "TE COMP" }
> db.Student.find().pretty();
{
"_id" : ObjectId("5b8fad4ef00832a0a50b5036"),
"Rno" : "1",
"Name" : "Piyush",
"Class" : "TE COMP"
}
{
"_id" : ObjectId("5b8fad62f00832a0a50b5037"),
"Rno" : "2",
"Name" : "Abhi",
"Class" : "TE COMP"}
{
"_id" : ObjectId("5b8fad70f00832a0a50b5038"),
"Rno" : "3",
"Name" : "Ashley",
"Class" : "TE COMP"
}
{
"_id" : ObjectId("5b8fad7ff00832a0a50b5039"),
"Rno" : "4",
"Name" : "Hitesh",
"Class" : "TE COMP"
}
{
"_id" : ObjectId("5b8fad8df00832a0a50b503a"),
"Rno" : "5",
"Name" : "Pratik",
"Class" : "TE COMP"
}
{
"_id" : ObjectId("5b8fada4f00832a0a50b503b"),
"Rno" : "6",
"Name" : "Pratik",
"Class" : "TE COMP"
}
> show dbs;
Abhi 0.078GB
admin (empty)
local 0.078GB
> db.Student.update({'Name':'Hitesh'},{$set:
{'Name':'Henry'}});WriteResult({ "nMatched" : 1, "nUpserted" : 0,
"nModified" : 1
})
> db.Student.find().pretty();
{
"_id" : ObjectId("5b8fad4ef00832a0a50b5036"),
"Rno" : "1",
"Name" : "Piyush",
"Class" : "TE COMP"
}
{
"_id" : ObjectId("5b8fad62f00832a0a50b5037"),
"Rno" : "2",
"Name" : "Abhi",
"Class" : "TE COMP"
}
{
"_id" : ObjectId("5b8fad70f00832a0a50b5038"),
"Rno" : "3",
"Name" : "Ashley",
"Class" : "TE COMP"
}
{
"_id" : ObjectId("5b8fad7ff00832a0a50b5039"),
"Rno" : "4",
"Name" : "Henry",
"Class" : "TE COMP"
}
{
"_id" : ObjectId("5b8fad8df00832a0a50b503a"),
"Rno" : "5",
"Name" : "Pratik",
"Class" : "TE COMP"}
{
"_id" : ObjectId("5b8fada4f00832a0a50b503b"),
"Rno" : "6",
"Name" : "Pratik",
"Class" : "TE COMP"
}
> db.Student.remove({'ADD':'MP'});
WriteResult({ "nRemoved" : 1 })
> db.Student.find().pretty();
{
"_id" : ObjectId("5b8fad62f00832a0a50b5037"),
"Rno" : "2",
"Name" : "Abhi",
"Class" : "TE COMP"
}
{
"_id" : ObjectId("5b8fad70f00832a0a50b5038"),
"Rno" : "3",
"Name" : "Ashley",
"Class" : "TE COMP"
}
{
"_id" : ObjectId("5b8fad7ff00832a0a50b5039"),
"Rno" : "4",
"Name" : "Henry",
"Class" : "TE COMP"
}
{
"_id" : ObjectId("5b8fad8df00832a0a50b503a"),
"Rno" : "5",
"Name" : "Pratik","Class" : "TE COMP"
}
{
"_id" : ObjectId("5b8fada4f00832a0a50b503b"),
"Rno" : "6",
"Name" : "Pratik",
"Class" : "TE COMP"
}
> db.Student.remove({'Name':'Pratik'},1);
WriteResult({ "nRemoved" : 1 })
> db.Student.remove({'Name':'Pratik'},1);
WriteResult({ "nRemoved" : 1 })
> db.Student.find().pretty();
{
"_id" : ObjectId("5b8fad62f00832a0a50b5037"),
"Rno" : "2",
"Name" : "Abhi",
"Class" : "TE COMP"
}
{
"_id" : ObjectId("5b8fad70f00832a0a50b5038"),
"Rno" : "3",
"Name" : "Ashley",
"Class" : "TE COMP"
}
{
"_id" : ObjectId("5b8fad7ff00832a0a50b5039"),
"Rno" : "4",
"Name" : "Henry",
"Class" : "TE COMP"
}

> db.Student.drop();true
> db.Student.find().pretty()
{ "ok" : 1 }
> db.Student.insert({'Rno':'1','Name':'Piyush','Class':'TE COMP'});
WriteResult({ "nInserted" : 1 })

> db.Student.insert({'Rno':'2','Name':'Abhi','Class':'TE COMP'});


WriteResult({ "nInserted" : 1 })

>db.Student.insert({'Rno':'3','Name':'Ashley','Class':'TE COMP'});
WriteResult({ "nInserted" : 1 })

> db.Student.insert({'Rno':'4','Name':'Hitesh','Class':'TE COMP'});


WriteResult({ "nInserted" : 1 })

> db.Student.insert({'Rno':'5','Name':'Pratik','Class':'TE COMP'});


WriteResult({ "nInserted" : 1 })

> db.Student.insert({'Rno':'6','Name':'Pratik','Class':'TE COMP'});


WriteResult({ "nInserted" : 1 })

> db.Student.find();
{ "_id" : ObjectId("5ba1d618f5bbacd4ad81568d"), "Rno" : "1",
"Name" : "Piyush", "Class" : "TE COMP" }
{ "_id" : ObjectId("5ba1d625f5bbacd4ad81568e"), "Rno" : "2",
"Name" : "Abhi", "Class" : "TE COMP" }
{ "_id" : ObjectId("5ba1d63af5bbacd4ad81568f"), "Rno" : "3",
"Name" : "Ashley", "Class" : "TE COMP" }
{ "_id" : ObjectId("5ba1d647f5bbacd4ad815690"), "Rno" : "4",
"Name" : "Hitesh", "Class" : "TE COMP" }
{ "_id" : ObjectId("5ba1d65ef5bbacd4ad815691"), "Rno" : "5",
"Name" : "Pratik", "Class" : "TE COMP" }
{ "_id" : ObjectId("5ba1d66df5bbacd4ad815692"), "Rno" : "6",
"Name" : "Pratik", "Class" : "TE COMP" }

> db.Student.find().pretty();
{
"_id" : ObjectId("5ba1d618f5bbacd4ad81568d"),
"Rno" : "1",
"Name" : "Piyush",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d625f5bbacd4ad81568e"),
"Rno" : "2","Name" : "Abhi",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d63af5bbacd4ad81568f"),
"Rno" : "3",
"Name" : "Ashley",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d647f5bbacd4ad815690"),
"Rno" : "4",
"Name" : "Hitesh",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d65ef5bbacd4ad815691"),
"Rno" : "5",
"Name" : "Pratik",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d66df5bbacd4ad815692"),
"Rno" : "6",
"Name" : "Pratik",
"Class" : "TE COMP"
}

> db.Student.update({'Name':'Hitesh'},{$set: {'Name':'Henry'}});


WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1})

> db.Student.find().pretty();
{
"_id" : ObjectId("5b8fad4ef00832a0a50b5036"),
"Rno" : "1",
"Name" : "Piyush",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5b8fad62f00832a0a50b5037"),
"Rno" : "2",
"Name" : "Abhi",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5b8fad70f00832a0a50b5038"),
"Rno" : "3",
"Name" : "Ashley",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5b8fad7ff00832a0a50b5039"),
"Rno" : "4",
"Name" : "Henry",
"Class" : "TE COMP"
}{ "_id" :
ObjectId("5b8fad8df00832a0a50b503a"),
"Rno" : "5",
"Name" : "Pratik",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5b8fada4f00832a0a50b503b"),"Rno" : "6",
"Name" : "Pratik",
"Class" : "TE COMP"
}

> db.Student.remove({'ADD':'MP'});
WriteResult({ "nRemoved" : 1 })

> db.Student.find().pretty();
{
"_id" : ObjectId("5b8fad62f00832a0a50b5037"),
"Rno" : "2",
"Name" : "Abhi",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5b8fad70f00832a0a50b5038"),
"Rno" : "3",
"Name" : "Ashley",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5b8fad7ff00832a0a50b5039"),
"Rno" : "4",
"Name" : "Henry",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5b8fad8df00832a0a50b503a"),
"Rno" : "5",
"Name" : "Pratik",
"Class" : "TE COMP"
} {"_id" :
ObjectId("5b8fada4f00832a0a50b503b"),
"Rno" : "6",
"Name" : "Pratik",
"Class" : "TE COMP"
}

>db.Student.save({_id:ObjectId("5b8fad4ef00832a0a50b5036"),"RNO
":"1","NAME":"PIYUSH","CLASS":"TE COMP","ADD":"MP"});
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1})

> db.Student.find().pretty();
{
"_id" : ObjectId("5b8fad4ef00832a0a50b5036"),
"RNO" : "1",
"NAME" : "PIYUSH",
"CLASS" : "TE COMP",
"ADD" : "MP"
}{
"_id" : ObjectId("5b8fad62f00832a0a50b5037"),
"Rno" : "2",
"Name" : "Abhi",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5b8fad70f00832a0a50b5038"),
"Rno" : "3",
"Name" : "Ashley",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5b8fad7ff00832a0a50b5039"),
"Rno" : "4","Name" : "Henry",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5b8fad8df00832a0a50b503a"),
"Rno" : "5",
"Name" : "Pratik",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5b8fada4f00832a0a50b503b"),
"Rno" : "6",
"Name" : "Pratik",
"Class" : "TE COMP"
}

> db.Student.find({$and:[{"Name":"Piyush"},{"Rno":"2"}]});

> db.Student.find({$and:[{"Name":"Piyush"},
{"Rno":"1"}]}).pretty();
{
"_id" : ObjectId("5ba1d618f5bbacd4ad81568d"),
"Rno" : "1",
"Name" : "Piyush",
"Class" : "TE COMP"
}

> db.Student.find({$and:[{"Name":"Piyush"},{"Rno":"2"}]}).pretty();

> db.Student.find({$or:[{"Name":"Piyush"},{"Rno":"2"}]}).pretty();
{
"_id" : ObjectId("5ba1d618f5bbacd4ad81568d"),
"Rno" : "1",
"Name" : "Piyush","Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d625f5bbacd4ad81568e"),
"Rno" : "2",
"Name" : "Abhi",
"Class" : "TE COMP"
}

> db.Student.find({$or:[{"Name":"Piyush"},{"Class":"TE
COMP"}]}).pretty();
{
"_id" : ObjectId("5ba1d618f5bbacd4ad81568d"),
"Rno" : "1",
"Name" : "Piyush",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d625f5bbacd4ad81568e"),
"Rno" : "2",
"Name" : "Abhi",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d63af5bbacd4ad81568f"),
"Rno" : "3",
"Name" : "Ashley",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d647f5bbacd4ad815690"),
"Rno" : "4",
"Name" : "Hitesh","Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d65ef5bbacd4ad815691"),
"Rno" : "5",
"Name" : "Pratik",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d66df5bbacd4ad815692"),
"Rno" : "6",
"Name" : "Pratik",
"Class" : "TE COMP"
}

> db.Student.find({$nor:[{"Name":"Piyush"},{"Class":"TE
COMP"}]}).pretty();

> db.Student.find({$nor:[{"Name":"Piyush"},
{"Rno":"2"}]}).pretty();
{
"_id" : ObjectId("5ba1d63af5bbacd4ad81568f"),
"Rno" : "3",
"Name" : "Ashley",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d647f5bbacd4ad815690"),
"Rno" : "4",
"Name" : "Hitesh",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d65ef5bbacd4ad815691"),"Rno" : "5",
"Name" : "Pratik",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d66df5bbacd4ad815692"),
"Rno" : "6",
"Name" : "Pratik",
"Class" : "TE COMP"
}
db.Student.find( {"Rno": { $not:{$lt:"3"}}}).pretty();
{
"_id" : ObjectId("5ba1d63af5bbacd4ad81568f"),
"Rno" : "3",
"Name" : "Ashley",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d647f5bbacd4ad815690"),
"Rno" : "4",
"Name" : "Hitesh",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d65ef5bbacd4ad815691"),
"Rno" : "5",
"Name" : "Pratik",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d66df5bbacd4ad815692"),
"Rno" : "6","Name" : "Pratik",
"Class" : "TE COMP"
}
> db.Student.find( {"Rno": { $eq:"5"}}).pretty();
{
"_id" : ObjectId("5ba1d65ef5bbacd4ad815691"),
"Rno" : "5",
"Name" : "Pratik",
"Class" : "TE COMP"
}

> db.Student.find( {"Rno": { $ne:"5"}}).pretty();


{
"_id" : ObjectId("5ba1d618f5bbacd4ad81568d"),
"Rno" : "1",
"Name" : "Piyush",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d625f5bbacd4ad81568e"),
"Rno" : "2",
"Name" : "Abhi",
"Class" : "TE COMP"
}{ "_id" :
ObjectId("5ba1d63af5bbacd4ad81568f"),
"Rno" : "3",
"Name" : "Ashley",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d647f5bbacd4ad815690"),
"Rno" : "4","Name" : "Hitesh",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d66df5bbacd4ad815692"),
"Rno" : "6",
"Name" : "Pratik",
"Class" : "TE COMP"
}

> db.Student.find( {"Rno": { $gt:"5"}}).pretty();


{
"_id" : ObjectId("5ba1d66df5bbacd4ad815692"),
"Rno" : "6",
"Name" : "Pratik",
"Class" : "TE COMP"
}
> db.Student.find( {"Rno": { $gte:"5"}}).pretty();
{
"_id" : ObjectId("5ba1d65ef5bbacd4ad815691"),
"Rno" : "5",
"Name" : "Pratik",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d66df5bbacd4ad815692"),
"Rno" : "6",
"Name" : "Pratik",
"Class" : "TE COMP"
}

> db.Student.find( {"Rno": { $lt:"5"}}).pretty();


{
"_id" : ObjectId("5ba1d618f5bbacd4ad81568d"),"Rno" : "1",
"Name" : "Piyush",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d625f5bbacd4ad81568e"),
"Rno" : "2",
"Name" : "Abhi",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d63af5bbacd4ad81568f"),
"Rno" : "3",
"Name" : "Ashley",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d647f5bbacd4ad815690"),
"Rno" : "4",
"Name" : "Hitesh",
"Class" : "TE COMP"
}

> db.Student.find( {"Rno": { $lte:"5"}}).pretty();


{
"_id" : ObjectId("5ba1d618f5bbacd4ad81568d"),
"Rno" : "1",
"Name" : "Piyush",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d625f5bbacd4ad81568e"),
"Rno" : "2","Name" : "Abhi",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d63af5bbacd4ad81568f"),
"Rno" : "3",
"Name" : "Ashley",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d647f5bbacd4ad815690"),
"Rno" : "4",
"Name" : "Hitesh",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d65ef5bbacd4ad815691"),
"Rno" : "5",
"Name" : "Pratik",
"Class" : "TE COMP"
}

> db.Student.find( {"Rno": { $lt:"5",$gt:"2"}}).pretty();


{
"_id" : ObjectId("5ba1d63af5bbacd4ad81568f"),
"Rno" : "3",
"Name" : "Ashley",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d647f5bbacd4ad815690"),
"Rno" : "4",
"Name" : "Hitesh","Class" : "TE COMP"
}

> db.Student.find( {"Rno": { $lte:"5",$gte:"2"}}).pretty();


{
"_id" : ObjectId("5ba1d625f5bbacd4ad81568e"),
"Rno" : "2",
"Name" : "Abhi",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d63af5bbacd4ad81568f"),
"Rno" : "3",
"Name" : "Ashley",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d647f5bbacd4ad815690"),
"Rno" : "4",
"Name" : "Hitesh",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d65ef5bbacd4ad815691"),
"Rno" : "5",
"Name" : "Pratik",
"Class" : "TE COMP"
}
> db.Student.find( {"Rno": { $lte:"5",$gt:"2"}}).pretty();
{
"_id" : ObjectId("5ba1d63af5bbacd4ad81568f"),
"Rno" : "3",
"Name" : "Ashley","Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d647f5bbacd4ad815690"),
"Rno" : "4",
"Name" : "Hitesh",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d65ef5bbacd4ad815691"),
"Rno" : "5",
"Name" : "Pratik",
"Class" : "TE COMP"
}

> db.Student.find( {"Rno": { $lt:"5",$gte:"2"}}).pretty();


{
"_id" : ObjectId("5ba1d625f5bbacd4ad81568e"),
"Rno" : "2",
"Name" : "Abhi",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d63af5bbacd4ad81568f"),
"Rno" : "3",
"Name" : "Ashley",
"Class" : "TE COMP"
}{
"_id" : ObjectId("5ba1d647f5bbacd4ad815690"),
"Rno" : "4",
"Name" : "Hitesh",
"Class" : "TE COMP"}

RESULT
Thus the CRUD operation in NoSQL database MongoDB has been successfully executed.
EXPERIMENT – 11
VIVA QUESTIONS

1. What is a NoSQL database, and how does it differ from traditional relational databases?
NoSQL databases are non-relational databases designed to handle large volumes of
unstructured or semi- structured data. They differ from traditional relational databases
by not using a fixed schema and offering flexible data models.
2. How do NoSQL databases handle date and time data?
NoSQL databases typically store date and time data in various formats, such as ISO
8601, Unix timestamps, or as native date types. The specific approach depends on the
database type and the data model it supports.
3. Give an example of a NoSQL database that excels in handling time-series data.
One example is InfluxDB, which is known for its efficient handling of time-series data,
making it suitable for applications involving metrics, monitoring, and IoT data.
4. Explain how MongoDB represents date and time data.
MongoDB represents date and time data using the BSON data type called ISODate. It
stores date and time in UTC format and allows for querying and indexing based on
time.
5. What is Apache Cassandra, and how does it handle date-related data?
Apache Cassandra is a distributed NoSQL database. It typically stores date and time
data as timestamps in microseconds or milliseconds, depending on the configuration. It
provides flexibility in handling time-related data.
6. How does CouchDB handle date and time information?
CouchDB stores date and time information as strings in JSON documents. It is left to
the application to choose the appropriate date format, allowing flexibility in
representing time.
7. In a time-series database like OpenTSDB, how is time represented?
OpenTSDB represents time as Unix timestamps (in seconds or milliseconds), providing
a convenient way to work with time-series data and allowing for efficient storage and
retrieval.
8. Can you explain how a graph database like Neo4j deals with date information?
Neo4j does not have a native date data type, but dates can be stored as properties with
appropriate formats ( e.g., strings or numeric representations). Date-related queries can
then be executed using the Cypher query language.
9. How do NoSQL databases handle the indexing of date fields?
NoSQL databases often provide indexing mechanisms for date fields to optimize query
performance. Indexing can be based on specific date attributes or the entire timestamp,
depending on the database.
10. Discuss the challenges and advantages of handling date and time data in NoSQL
databases.
Challenges may include consistency across distributed systems, while advantages
include flexibility in data models, scalability, and efficient handling of time-series data.
EX.NO:12 GUI BASED DATABASE APPLICATIONS
DATE:

AIM:
To implement an online exam registration page with database connectivity using php

ALGORITHM:

STEP 1: Develop a webpage which includes all the fields for registering for an online exam
STEP 2: Develop a PHP page which receives the values that are given as an input in the registration page
STEP 3: Connect the registration page with the PHP page
STEP 4: Receive the values from registration page
STEP 5: Establish a connection with the database
STEP 6: Store the received values in the database

PROGRAM:

Registration.html

<html>
<body bgcolor="lightblue">
<p><center>REGISTRATION FORM</center></p>
<form action="Registration.php" method="post">
<center><pre><b> Student name: <input type="text" name="n" value=" ">
Register Number: <input type="text" name="reg" value=" ">
CGPA: <input type="text" name="cgpa" value=" ">
YEAR: <input type="text" name="y" value=" ">
Branch: <input type="text" name="branch" value=" ">
<input type="submit" name="button" value="SUBMIT">
</b></center></pre>
</body>
</html>

Registration.php

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "Online_exam";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
/*else
echo "Connection established";*/

$Name=$_POST['n'];
$RegNo=$_POST['reg'];
$CGPA=$_POST['cgpa'];
$Year=$_POST['y'];
$Branch=$_POST['branch'];
/*echo $Name;
echo $RegNo;
echo $CGPA;
echo $Year;
echo $Branch;*/
$sql = "CREATE TABLE regDetails(Name varchar(30) not null, RegNo int(15) not null,CGPA float
not null, Year varchar(5) not null, Branch varchar(5) not null)";

if ($conn->query($sql) === TRUE)


{
echo "Table regDetails created successfully";
}
else
{
echo "Error creating table: " . $conn->error;
}
$sql = "INSERT INTO regDetails (Name,RegNo,CGPA,Year,Branch)
VALUES ('$Name',$RegNo,$CGPA,'$Year','$Branch')";
if ($conn->query($sql) === TRUE)
{
echo "New record created successfully";
}
else
{
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>

RESULT:
Thus the real life database application for exam registration has been successfully executed.
EXPERIMENT – 12
VIVA QUESTIONS
1. What is a GUI-based database application?
A GUI-based database application is a software application that provides a graphical
user interface (GUI) for users to interact with a database. It allows users to perform
database operations, such as querying, inserting, updating, and deleting records, using
visual elements
2. How does a GUI-based database application differ from a command-line interface
(CLI) application?
A GUI-based application uses graphical elements like buttons, forms, and menus to
interact with the database, providing a more user-friendly and visually intuitive
experience compared to a command-line interface that relies on text commands.
3. What are the advantages of using a GUI for database applications?
GUIs offer advantages such as ease of use, reduced learning curve, visual representation
of data, and the ability to provide feedback to users through interactive elements,
enhancing the overall user experience.
4. Can you name a popular GUI-based database application development tool?
Examples include Microsoft Access, Oracle Forms, and File-Maker Pro.
5. How does a user typically interact with a GUI-based database application?
Users interact with a GUI-based database application by clicking buttons, filling out
forms, selecting options from menus, and manipulating visual elements to perform
various database operations.
6. Explain the concept of data binding in the context of GUI-based database applications.
Data binding is the process of connecting the user interface elements (such as text boxes
or tables) directly to the underlying database, allowing changes in the UI to be reflected
in the database and vice versa.
7. What is the role of forms in GUI-based database applications?
Forms in GUI-based database applications serve as a means for users to input and view
data. They typically consist of fields corresponding to database columns, and users
interact with these forms to perform operations on the data.
8. How can GUI-based applications handle database transactions?
GUI-based applications often provide transaction management features, allowing users
to initiate and commit transactions or roll back changes. This ensures data consistency
and integrity.
9. Discuss the importance of validation in GUI-based database applications.
Validation in GUI-based applications is crucial to ensure that data entered by users
meets specified criteria. This helps maintain data integrity and prevents the insertion of
incorrect or inconsistent information into the database.
10. What is view in sql?
In SQL, a view is a virtual table based on the result-set of an SQL statement. A view
contains rows and columns, just like a real table. The fields in a view are fields from
one or more real tables in the database.
EX.NO:13 DATABASE DESIGN USING ER MODELING, NORMALIZATION AND
DATE : IMPLEMENTATION FOR ANY APPLICATION

AIM:
To implement Database Design using ER modeling, normalization for an application

ALGORITHM:

STEP 1: Create a database schema for an application


STEP 2: Draw an E-R diagram for the schema
STEP 3: Check for atomic values and change it to first normal form
STEP 4: Check for functional dependency and modify the schema to second normal form
STEP 5: Check for transitive dependency and convert to third normal form
STEP 6: Check that every determinant is a candidate key and convert to Boyce Codd normal form
STEP 7: Check for multi-valued dependency and change it to fourth normal form
STEP 8: Check whether the table is fully normalized

First Normal Form:


 It should only have single(atomic) valued attributes/columns.
 Values stored in a column should be of the same domain
 All the columns in a table should have unique names

Changing it to 1NF:

Second Normal Form (2NF)

For a table to be in the Second Normal Form,

1. It should be in the First Normal form.


2. And, it should not have Partial Dependency.
Student:

Subject:

Score:

Changing it to 2NF:

Third Normal Form (3NF)


For a table to be in the third normal form,
1. It should be in the Second Normal form.
2. And it should not have Transitive Dependency.
RESULT:
Thus normalization has been implemented for student database successfully
EXPERIMENT – 13
VIVA QUESTIONS

1. What is ER modeling, and why is it important in database design?


ER modeling is a graphical representation technique used to model the data
requirements and relationships in a system. It's essential in database design to visually
depict entities, their attributes, and the relationships between them.
2. Explain the key components of an ER diagram.
The key components of an ER diagram include entities, attributes, relationships, and
cardinality. Entities represent real-world objects, attributes are properties of entities,
relationships describe associations between entities, and cardinality defines the
numerical relationship between entities in a relationship.
3. How do you represent a one-to-many relationship in an ER diagram?
In an ER diagram, a one-to-many relationship is represented by drawing a line
connecting the entities involved in the relationship and adding a crow's foot notation
on the "many" side.
4. What is the purpose of carnality in an ER diagram?
Carnality in an ER diagram defines the number of instances of one entity that can be
associated with the number of instances of another entity in a relationship. It helps
specify the nature and constraints of the relationship.
5. Can an entity have more than one key attribute?
Yes, an entity can have multiple key attributes, and these are often referred to as
composite keys. Composite keys are useful when a single attribute cannot uniquely
identify an entity.
6. What is the difference between a superkey and a candidate key?
A superkey is a set of one or more attributes that, taken collectively, uniquely
identifies an entity. A candidate key is a minimal superkey, meaning no subset of it
can uniquely identify an entity.
7. How does normalization help in reducing data redundancy?
Normalization reduces data redundancy by organizing data in such a way that each
piece of information is stored in only one place. This eliminates the need to update
multiple copies of the same data, reducing the risk of inconsistencies
8. Explain the concept of transitive dependency.
Transitive dependency occurs when a non-prime attribute is functionally dependent
on another non-prime attribute rather than the primary key. Normalization aims to
eliminate transitive dependencies.
9. What is the role of SQL in database implementation?
SQL (Structured Query Language) is used for implementing, querying, and managing
relational databases. It provides commands for creating tables, defining relationships,
inserting, updating, and retrieving data.
10. How do you create a table in a relational database using SQL?
You create a table in SQL using the CREATE TABLE statement, specifying the table
name and its columns along with their data types and constraints.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy