Professional Documents
Culture Documents
Advance Database Lab
Advance Database Lab
Advance Database Lab
NO:1
DATE :
TO IMPLEMENT DDL AND DML COMMANDS IN RDBMS
AIM:
To execute and verify the DDL and DML commands in rdbms.
DDL (DATA DEFINITION LANGUAGE)
CREATE
ALTER
DROP
TRUNCATE
COMMENT
RENAME
DML (DATA MANIPULATION LANGUAGE)
SELECT
INSERT
DELETE
UPDATE
in the database.
of database
objects.
in the database.
QUERY: 03
1 Row Created.
1 Row Created.
1 Row Created.
1 Row Created.
QUERY: 04
TABLE 02:
SQL>Create Table bookstore (store number Number(10), city Varchar(50),
State Varchar(50), PINcode Number(10), Inventory values Number(10));
Table created.
SQL> DESC bookstores;
Name Null? Type
----------------------------- -------- -------------
storenumber Number(10)
city Varchar(50)
State Varchar(50)
PINcode Number(10)
Inventoryvalues Number(10)
1 Row Created.
1 Row Created.
1 Row Created.
1 Row Created.
1 Row Created.
SQL> SELECT * FROM bookstore;
TABLE 03:
SQL>Create Table stock (store number Number(10), ISBN alphanumeric(10),
Quantity Number(10));
Table created.
SQL> DESC bookstores;
Name Null? Type
----------------------------- -------- -------------
storenumber Number(10)
ISBN Alphanumeric(10)
Quantity Number(10)
1 Row Created.
Sql>Insert Into Stock Values(122,ISBN1346,10);
1 Row Created.
1 Row Created.
1 Row Created.
1 Row Created.
122 ISBN1346 10
133 ISBN1347 15
141 ISBN1348 5
155 ISBN1349 10
Query 05:
Q5:Write the query for finding price in books between 15 and 55.
HTML BOOK 50
QUERY: 06
1 row updated.
RESULT:
Thus DDL and DML has been created, executed and verified successfully.
Ex.no: OBJECT ORIENTED DATABASE
Date:
Aim:
To dsign an Enhanced Entity Relationship (EER) Model for university database by using Matisse
Enterprise manager.
Write OQL for the following
i. Insert details in each object.
ii. Display the Employee details.
iii. Display Student Details.
iv. Modify person details.
v. Delete person details.
Procedure:
Step 1: Download the Matisse Enterprise manager from www.matisse .com .
Step 2: Open matisse as follows
Start->All programs->Enterprise manager
Step 3: To create new database click on example and turn on it. Extend it by
clicking on ‘+’ sign then click on data to use Sql Query Analyzer.
Example->Data->SQL Query Analyzer
Step 4:TO CREATE CLASSES:
Use queries inside the box SQL statement and excute it.
Create Classes called Student then Employee and then Univ
Q1: CREATE CLASS Student (name string, regno integer,department string,
emp REFERENCES SET (Employee) INVERSE Employee.starred_in,
ownedby REFERENCES (Univ) INVERSE Univ.owns);
Q2: CREATE CLASS Employee (name string, street string, city string,
starred_in REFERENCES SET (Student) INVERSE Student.emp);
Execute query by using F5 and then execution result will be at the bottom of SQL statement
box.
Step 5: TO INSERT THE VALUES:
Student details:
Employee details:
Step 7: TO MODIFY THE DETAILS
update Student s set s.name='mano' where s.name='ani';
Extend these
Example->Meta Schema->Classes->UML Diagram
Step 10: Stop after creating, inserting, updating, and deleting the details
RESULT:
Thus an Enhanced Entity Relationship (EER) Model for university database by using Matisse
Enterprise manager has been created and successfully executed the following
i. Insert details in each object.
ii. Display the Employee details.
iii. Display Student Details.
iv. Modify person details.
v. Delete person details
RESULT:
Parallel database -1
AIM:
To develop an university counselling application for engineering
colleges.
Software Objective:
The college, department and vacancy details are maintained in 3 sites.
Students are allocated colleges in these 3 sites simultaneously. Implement this
application using parallel database. [State any assumptions you have made].
Assumption Made:
Two forms are created for viewing available seats and allocating seats.
The first form will view only the available seats in each site. The second form is
used to allocate seats for students. If a seat is allocated to a student, all the 3
sites are updated in parallel.
Implementation:
Codes:
Public Class Form2
Me.Close()
End Sub
'open connection
cnn.Open()
End If
da.Fill(dt)
db.Fill(du)
dc.Fill(dv)
Me.Site1DataGridView.DataSource = dt
Me.Site2DataGridView.DataSource = du
Me.Site3DataGridView.DataSource = dv
'close connection
cnn.Close()
End Sub
Me.Validate()
Me.Site1BindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.Database1DataSet)
End Sub
Me.Site3TableAdapter1.Fill(Me.Database1DataSet1.Site3)
'TODO: This line of code loads data into the 'Database1DataSet1.Site2' table. You can move,
or remove it, as needed.
Me.Site2TableAdapter1.Fill(Me.Database1DataSet1.Site2)
'TODO: This line of code loads data into the 'Database1DataSet1.Site1' table. You can move,
or remove it, as needed.
Me.Site1TableAdapter1.Fill(Me.Database1DataSet1.Site1)
'TODO: This line of code loads data into the 'Database1DataSet.Site3' table. You can move,
or remove it, as needed.
Me.RefreshData()
End Sub
cnn.Open()
End If
cmd.Connection = cnn
cmd.ExecuteNonQuery()
cmd.CommandText = "UPDATE Site2 SET Vacancy = Vacancy - 1 Where (CollegeName='"
& Me.TextBox3.Text & "')"
cmd.ExecuteNonQuery()
cmd.ExecuteNonQuery()
RefreshData()
'clear form
'close connection
cnn.Close()
End Sub
End Sub
End Class
Conclusion:
This software provides an efficient way of managing university
counselling application for engineering colleges.
Parallel database -2
AIM:
To implement parallel join and parallel sort algorithms to get marks from
different colleges of the university and publish 10 ranks for each discipline.
Objective:
There are 5 processors working in parallel environment and producing
output. The output record contains college details and student mark information.
Implement parallel join and parallel sort algorithms to get the marks from different
colleges of the university and publish 10 ranks for each discipline.
Assumption Made:
Five tables are created in which each table represents a college. Each table
contains various departments and its overall percentage. Query is written to extract
the details from all the 5 tables in parallel and colleges are arranged based on their
department overall percentage.
Implementation:
Creating of Tables
SQL> create table REC (id int, collg varchar(20), cse int, mech int, it int, civil int, ece int);
Table created.
SQL> create table PEC (id int, collg varchar(20), cse int, mech int, it int, civil int, ece int);
Table created.
SQL> create table APEC (id int, collg varchar(20), cse int, mech int, it int, civil int, ece int);
Table created.
SQL> create table SSN (id int, collg varchar(20), cse int, mech int, it int, civil int, ece int);
Table created.
SQL> create table SVCE (id int, collg varchar(20), cse int, mech int, it int, civil int, ece int);
Table created.
Conclusion:
This software provides an efficient way of managing university counselling
application for engineering colleges
SQL> insert into REC values(1,'REC',88,74,90,98,77);
1 row created.
ECE
----------
1 REC 88 74 90 98
77
1 row created.
1 row created.
1 row created.
ECE
----------
1 REC 88 74 90 98
77
2 ;
ECE
----------
1 PEC 70 78 80 82
80
SQL> select * from ssn;
ECE
----------
1 SSN 72 73 88 76
67
ECE
----------
1 SVCE 68 64 60 91
90
ECE
----------
1 APEC 80 71 92 90
70
CSE MECH
---------- ----------
88 74
SQL> select CSE from REC union select CSE from apec;
CSE
----------
80
88
SQL> select CSE from REC union select cse from apec order by desc;
select CSE from REC union select cse from apec order by desc
ERROR at line 1:
SQL> select collg,CSE,mech,it,civil from rec union select collg,cse,mech,it,civil from apec order by
cse desc;
REC 88 74 90 98
APEC 80 71 92 90
SQL> select collg,CSE from rec union select collg,cse from apec union select collg,cse from pec unio
n select collg,cse from ssn union select collg,cse from ssn order by cse;
COLLG CSE
-------------------- ----------
PEC 70
SSN 72
APEC 80
REC 88
SQL> select collg,CSE from rec union select collg,cse from apec union select collg,cse from pec unio
n select collg,cse from ssn union select collg,cse from ssn union select collg,cse from svce order b
y cse;
COLLG CSE
-------------------- ----------
SVCE 68
PEC 70
SSN 72
APEC 80
REC 88
SQL> select collg,mech from rec union select collg,mech from apec union select collg,mech from pec u
nion select collg,mech from ssn union select collg,mech from svce order by mech;
COLLG MECH
-------------------- ----------
SVCE 64
APEC 71
SSN 73
REC 74
PEC 78
SQL> select collg,mech from rec union select collg,mech from apec union select collg,mech from pec u
nion select collg,mech from ssn union select collg,mech from svce order by mech desc;
COLLG MECH
-------------------- ----------
PEC 78
REC 74
SSN 73
APEC 71
SVCE 64
SQL> select collg,mech from rec union select collg,mech from apec union select collg,mech from pec u
nion select collg,mech from ssn union select collg,mech from svce order by mech union select collg,m
ech from rec union select collg,cse from apec union select collg,cse from pec union select collg,cse
select collg,mech from rec union select collg,mech from apec union select collg,mech from pec union
ERROR at line 1:
SQL> select collg,mech from rec union select collg,mech from apec union select collg,mech from pec u
nion select collg,mech from ssn union select collg,mech from svce order by mech ;unionselect collg,m
ech from rec union select collg,cse from apec union select collg,cse from pec union select collg,cse
select collg,mech from rec union select collg,mech from apec union select collg,mech from pec union
ERROR at line 1:
SQL> select collg,it from rec union select collg,it from apec union select collg,it from pec union s
elect collg,it from ssn union select collg,it from svce order by it;
COLLG IT
-------------------- ----------
SVCE 60
PEC 80
SSN 88
REC 90
APEC 92
SQL> select collg,ece from rec union select collg,ece from apec union select collg,ece from pec unio
n select collg,ece from ssn union select collg,ece from svce order by ece;
COLLG ECE
-------------------- ----------
SSN 67
APEC 70
REC 77
PEC 80
SVCE 90
SQL> select collg,civil from rec union select collg,civil from apec union select collg,civil from pe
c union select collg,civil from ssn union select collg,civil from svce order by civil;
COLLG CIVIL
-------------------- ----------
SSN 76
PEC 82
APEC 90
SVCE 91
REC 98
SQL>
SQL> ((select collg,mech from rec union select collg,mech from apec union select collg,mech from pec
union select collg,mech from ssn union select collg,mech from svce order by mech desc )
2 union
3 (select collg,cse from rec union select collg,cse from apec union select collg,cse from pec uni
on select collg,cse from ssn union select collg,cse from svce order by cse desc)
4 union
5 (select collg,it from rec union select collg,it from apec union select collg,it from pec union
select collg,it from ssn union select collg,it from svce order by it desc)
6 union
7 (select collg,ece from rec union select collg,ece from apec union select collg,ece from pec uni
on select collg,ece from ssn union select collg,ece from svce order by ece desc)
8 union
9 (select collg,civil from rec union select collg,civil from apec union select collg,civil from p
ec union select collg,civil from ssn union select collg,civil from svce order by civil desc));
((select collg,mech from rec union select collg,mech from apec union select collg,mech from pec unio
ERROR at line 1:
ECE
----------
1 APEC 80 71 92 90
70
ECE
----------
1 APEC 80 71 92 90
70
1 REC 88 74 90 98
77
SQL> (select collg,mech from rec union select collg,mech from apec union select collg,mech from pec
union select collg,mech from ssn union select collg,mech from svce order by mech desc )
2 union
3 (select collg,cse from rec union select collg,cse from apec union select collg,cse from pec uni
on select collg,cse from ssn union select collg,cse from svce order by cse desc)
4 union
5 (select collg,it from rec union select collg,it from apec union select collg,it from pec union
select collg,it from ssn union select collg,it from svce order by it desc)
6 union
7 (select collg,ece from rec union select collg,ece from apec union select collg,ece from pec uni
on select collg,ece from ssn union select collg,ece from svce order by ece desc)
8 union
9 (select collg,civil from rec union select collg,civil from apec union select collg,civil from p
ec union select collg,civil from ssn union select collg,civil from svce order by civil desc);
(select collg,mech from rec union select collg,mech from apec union select collg,mech from pec union
ERROR at line 1:
SQL> (select collg,mech from rec union select collg,mech from apec union select collg,mech from pec
union select collg,mech from ssn union select collg,mech from svce order by mech desc )
2 union
3 (select collg,cse from rec union select collg,cse from apec union select collg,cse from pec uni
on select collg,cse from ssn union select collg,cse from svce order by cse desc)
4 ;
(select collg,mech from rec union select collg,mech from apec union select collg,mech from pec union
ERROR at line 1:
SQL> (select collg,mech from rec union select collg,mech from apec union select collg,mech from pec
union select collg,mech from ssn union select collg,mech from svce order by mech desc );
(select collg,mech from rec union select collg,mech from apec union select collg,mech from pec union
ERROR at line 1:
SQL> (select collg,cse from rec union select collg,cse from apec union select collg,cse from pec uni
on select collg,cse from ssn union select collg,cse from svce order by cse desc);
(select collg,cse from rec union select collg,cse from apec union select collg,cse from pec union se
ERROR at line 1:
SQL> ((select collg,mech from rec) union (select collg,mech from apec)union (select collg,mech from
pec) union (select collg,mech from ssn) union (select collg,mech from svce order by mech desc) );
((select collg,mech from rec) union (select collg,mech from apec)union (select collg,mech from pec)
ERROR at line 1:
SQL> (select collg,cse from REC) union (select collg,cse from apec) order by cse;
COLLG CSE
-------------------- ----------
APEC 80
REC 88
SQL> (select collg,mech from rec) union (select collg,mech from apec)union (select collg,mech from p
ec) union (select collg,mech from ssn) union (select collg,mech from svce) order by mech desc;
COLLG MECH
-------------------- ----------
PEC 78
REC 74
SSN 73
APEC 71
SVCE 64
SQL> ((select collg,mech from rec) union (select collg,mech from apec) order by mech desc) union (se
lect collg,mech from rec) union (select collg,mech from apec) order by mech desc));
((select collg,mech from rec) union (select collg,mech from apec) order by mech desc) union (select
ERROR at line 1:
SQL> select collg,mech from rec union select collg,mech from apec union select collg,mech from pec u
nion select collg,mech from ssn union select collg,mech from svce order by mech desc
2 union
3 select collg,mech from rec union select collg,mech from apec union select collg,mech from pec u
nion select collg,mech from ssn union select collg,mech from svce order by mech desc;
union
ERROR at line 2:
SQL> select collg,mech from rec union select collg,mech from apec union select collg,mech from pec u
nion select collg,mech from ssn union select collg,mech from svce order by mech desc;
COLLG MECH
-------------------- ----------
PEC 78
REC 74
SSN 73
APEC 71
SVCE 64
SQL> commit
2 l
SQL> commit;
Commit complete.
SQL>
Ex.No:6 ACTIVE DATABASE
Date:
AIM:
To create triggers and assertions for Bank database handling deposits and loan and
admission database handling seat allocation and vacancy position.
PROCEDURE:
STEP 1:
Create a trigger for updating customers account and bank account when a deposit is made
by an customer.
Syntax:
Table Created.
Table Created.
Query3: create table deposit(deposit_id number,bank_no number,acc_no number,amount
number,foreign key (acc_no) references cust(acc_no),foreign key (bank_no) references
bank(bank_no));
Table Created.
Sequence Created.
Table Created.
Sequence Created.
Trigger 1:
create or replace
trigger deposit_trg
begin
end;
Statement Processed.
Trigger 2:
create or replace
trigger loan1_trg
begin
end;
Statement Processed.
1 row(s) inserted.
1 row(s) inserted.
1 row(s) inserted.
1 row(s) inserted.
1 row(s) inserted.
1 row(s) inserted.
Query15: select * from bank;
Query16:select * from cust;
STEP 2:
Create a trigger for updating customer’s loan account and bank account when a loan is
issued to the customer.
Syntax:
Table Created.
Query2: create table cust(acc_no number primary key,cust_name varchar2(50),acc_type
varchar2(15),balance number);
Table Created.
Table Created.
Sequence Created.
Trigger 1:
create or replace
trigger loan3_trg
begin
end;
Statement Processed.
1 row(s) inserted.
1 row(s) inserted.
Query7: insert into cust values(1234,'SANTHOSH','SAVINGS',1500);
1 row(s) inserted.
1 row(s) inserted.
1 row(s) inserted.
Create assertion for bank database so that the total loan amount does not exceed the total
balance in the bank.
Syntax:
Table Created.
Table Created.
Sequence Created.
Trigger 1:
create or replace
trigger loan3_trg
begin
end;
Statement Processed.
1 row(s) inserted.
1 row(s) inserted.
STEP 4:
Create a trigger for updating the seat selection details and vacancy position, when an
admission is made.
Syntax:
Table Created.
Table Created.
Table Created.
Trigger 1:
create or replace
trigger selection_trg
begin
end;
Statement Processed.
1 row(s) inserted.
Query6: select * from selection;
Query7: select * from admission;
RESULT:
Thus the triggers and assertions has been created, executed and verified
successfully.
Ex.No:7 DEDUCTIVE DATABASE
Date:
AIM:
To construct a knowledge database for kinship domain (family relations) with facts.
Extract the following relations using rules:
Parent, Sibling, Brother, Sister, Child, Daughter, Son, Spouse, Wife, husband, Grandparent,
Grandchild, Cousin, Aunt and Uncle.
PROCEDURE:
1. Start
2. Download the Prolog 7.1.11 software and install it.
3. Open Prolog 7.1.11 and click onto the File -> New and save the filename with
filename.pl and click save.
4. Type the program and save it as File -> Save buffer and close the current window.
5. Open the Main window and type consult(filename). to compile the program.
6. If it is true then the program has no errors.
7. Then check for each and every condition.
8. Terminate the program.
PROGRAM:
Step 1:
In the edit window type the following code. Describe each and every conditions and
relations here.
male(raja).
male(bharani).
male(pandithurai).
male(kannan).
male(semban).
male(ragul).
female(ranimuthu).
female(poorni).
female(anburani).
female(jansi).
female(moni).
female(vaishu).
female(inbam).
female(nive).
parent(anburani,pandithurai).
parent(anburani,ranimuthu).
parent(anburani,jansi).
parent(semban,raja).
parent(seemban,kannan).
parent(semban,inbam).
parent(raja,bharani).
parent(raja,poorni).
parent(raja,rahul).
parent(ranimuthu,bharani).
parent(ranimuthu,poorni).
parent(ranimuthu,rahul).
parent(jansi,moni).
parent(jansi,vaishu).
parent(kannan,moni).
parent(kannan,vaishu).
parent(pandithurai,nive).
married(raja,ranimuthu).
married(kannan,jansi).
Step 2:
Compile and run the coding for all the relations given above.
RESULT:
Thus the Deuctive Database for Kinship domain with facts are executed and verified
successfully.
EX.NO:8 WEKA TOOL
DATE:
AIM:
To work with weka tool classification and clustering algorithms for
the given training data and test with unknown samples.
WHAT IS WEKA?
WEKA stands for Waikato Environment for Knowledge
Learning. It was developed by the University of Waikato, New
Zealand.
WEKA supports many data mining and machine learning
algorithms, including data re-processing, classification, clustering,
regression and association rule extraction.
The workflow of WEKA would be as follows:
Data->Pre-processing->Data Mining-> Knowledge
PROCEDURE:
Step 1: From windows desktop,
click “Start”, choose “All programs”,
Choose “Weka 3.7” to start Weka
Then the first interface window appears:
Weka GUI Chooser Window
Step 2: Create one file in ARFF file format in notepad.
An ARFF file consists of two distinct sections:
The Header section defines attribute name, type and
relations, start with a keyword.
@Relation <data-name>
@attribute <attribute-name> <type> or {range}
The Data section lists the data records, starts with
@Data list of data instances
Any line start with % is the comments.
Step 8: Once the options have been specified, we can run the
classification algorithm. Click on ‘Start’ button to start the learning
process. We can stop learning process at any time by clicking on ‘Stop’
button.
When training set is complete, the ‘Classifier’ output area on the
right panel of ‘Classify’ window is filled with text describing the
results of training and testing. A new entry appears in the ‘Result
list’ box on the left panel of ‘Classify’ window.
Sept 9: Visualization of Results
After training a classifier, the result list adds an entry. WEKA lets we to
see a graphical representation of the classification tree. Right-click on
the entry in ‘Result list’ for which we would like to visualize a tree. It
invokes a menu containing the following items:
outlook = sunny
| humidity <= 75: yes (2.0)
| humidity > 75: no (3.0)
outlook = overcast: yes (4.0)
outlook = rainy
| windy = TRUE: no (2.0)
| windy = FALSE: yes (3.0)
Number of Leaves : 5
TP Rate FP Rate Precision Recall F-Measure MCC ROC Area PRC Area Class
1.000 0.000 1.000 1.000 1.000 1.000 1.000 1.000 yes
1.000 0.000 1.000 1.000 1.000 1.000 1.000 1.000 no
Weighted
Avg. 1.000 0.000 1.000 1.000 1.000 1.000 1.000 1.000
a b <-- classified as
9 0 | a = yes
0 5 | b = no
Stucture of tree:
kMeans
======
Number of iterations: 3
Within cluster sum of squared errors: 16.237456311387238
Missing values globally replaced with mean/mode
Cluster centroids:
Cluster#
Attribute Full Data 0 1
(14) (9) (5)
==============================================
outlook sunny sunny overcast
temperature 73.5714 75.8889 69.4
humidity 81.6429 84.1111 77.2
windy FALSE FALSE TRUE
play yes yes yes
Clustered Instances
0 9 ( 64%)
1 5 ( 36%)
Step 13: Visualization of Results
Another way of representation of results of clustering is through
visualization. Right-click on the entry in the ‘Result list’ and select
‘Visualize cluster assignments’ in the pull-down window.
Step 14:
This brings up the ‘Weka Clusterer Visualize’ window. On the
‘Weka Clusterer Visualize’ window, beneath the X-axis selector
there is a dropdown list, ‘Colour’, for choosing the color scheme.
This allows we to choose the color of points based on the attribute
selected. Below the plot area, there is a legend that describes what
values the colors correspond to.. Leftclick on ‘3’ in the ‘Class
colour’ box and select lighter color from the color palette.
To the right of the plot area there are series of horizontal strips.
Each strip represents an attribute, and the dots within it show the
distribution values of the attribute. we can choose what axes are
used in the main graph by clicking on these strips (left-click
changes X-axis, right31 click changes Y-axis).
RESULT:
Thus worked with weka tool, classification and clustering algorithms for
the given training data and test with unknown samples are created,
executed and verified successfully.
Query Processing
AIM:
To implement query optimizer with relational algebraic expression
construction and execution plan generation for choosing an efficient execution
strategy for processing the given query
Objective:
To design employee database and test the algorithm with following sample
queries,
2. Optimization
– Generate an optimal evaluation plan (with lowest cost) for the query plan.
3. Evaluation
Among all semantically equivalent expressions, the one withthe least costly
evaluation plan is chosen. Cost estimate of aplan is based on statistical information
in the system catalogues.
σempid,empname,experience,empid,branch,designation(employeeᐅᐊbranch
es)
4. View the employee id and branch alone from two tables using join.
πempid,branch (employeeᐅᐊbranches)
5. Select all the employees who have experience more than ten years.
σ experience>10 (employee)
Conclusion:
Thus, to implement query optimizer with relational algebraic expression
construction and execution plan generation for choosing an efficient execution
strategy for processing the given query is executed and implemented successfully.
Aim :
Design XML Schema for the given company database
deptLocation )
1)Retrieve the department name, manager name, and manager salary for every
department’
2)Retrieve the employee name, supervisor name and employee salary for each
and total hours worked per week on the project for each project.
and total hours worked per week on the project for each project with more than
b.Implement a storage structure for storing XML database and test with the above
schema.
5) Select tables -> Create a new table -> give table name
click next till finish. Anew table will be created.
7) give column name as per the table and the data type, for instance, Employee ( empName, empSSN,
empSex, empSalary, empBirthDate, empDeptNo, empSupervisorSSN, empAddress, empWorksOn)
Go to Command editor or click Query link which is present at the bottom link by clicking any table