Database Design Management Lab Manual
Database Design Management Lab Manual
MANAGEMENT SYSTEMS
3. Implement the database using SQL Data definition with constraints, Views
AIM:
To execute and verify the Data Definition Language commands and constraints
❖ ALTER
❖ DROP
❖ TRUNCATE
❖ COMMENT
❖ RENAME
PROCEDURE
STEP 1: Start
STEP 3: Execute different Commands and extract information from the table.
STEP 4: Stop
SQL COMMANDS
1. COMMAND NAME: CREATE
COMMAND DESCRIPTION: CREATE command is used to create objects
in the database.
2. COMMAND NAME: DROP
COMMAND DESCRIPTION: DROP command is used to delete the object
from the database.
3. COMMAND NAME: TRUNCATE
COMMAND DESCRIPTION: TRUNCATE command is used to remove
all the records from the table
4. COMMAND NAME: ALTER
COMMAND DESCRIPTION: ALTER command is used to alter the structure of
database
5. COMMAND NAME: RENAME
COMMAND DESCRIPTION: RENAME command is used to rename the objects.
QUERY: 01
Q1. Write a query to create a table employee with empno, ename, designation, and
salary.
QUERY: 01
QUERY: 02
Q2. Write a query to display the column name and datatype of the table employee.
Q3. Write a query for create a from an existing table with all the fields
QUERY: 03
QUERY: 04
Q4. Write a query for create a from an existing table with selected fields
QUERY: 04
QUERY: 05
Q5. Write a query for create a new table from an existing table without any record:
Syntax for create a new table from an existing table without any record:
QUERY: 05
SQL> CREATE TABLE EMP3 AS SELECT * FROM EMP WHERE
1>2;
Table created.
QUERY: 06
Q6. Write a Query to Alter the column EMPNO NUMBER (4) TO EMPNO NUMBER
(6).
QUERY: 06
SQL>ALTER TABLE EMP MODIFY EMPNO NUMBER (6);
Table altered.
SQL> DESC EMP;
Name Null? Type
----------------------------------------- --------
---------------------------- EMPNO NUMBER(6)
ENAME VARCHAR2(10)
DESIGNATIN VARCHAR2(10)
SALARY NUMBER(8,2)
QUERY: 07
Q7. Write a Query to Alter the table employee with multiple columns (EMPNO,
ENAME.)
QUERY: 07
QUERY: 08
Q8. Write a query to add a new column in to employee
Syntax for add a new column:
SQL> ALTER TABLE <TABLE NAME> ADD (<COLUMN NAME> <DATA
TYPE> <SIZE>);
QUERY: 08
SQL> ALTER TABLE EMP ADD QUALIFICATION VARCHAR2(6);
Table altered.
SQL> DESC EMP;
Name Null? Type
----------------------------------------- --------
---------------------------- EMPNO NUMBER(7)
ENAME VARCHAR2(12)
DESIGNATIN VARCHAR2(10)
SALARY NUMBER(8,2)
QUALIFICATION VARCHAR2(6)
QUERY: 09
Q9. Write a query to add multiple columns in to employee
Syntax for add a new column:
SQL> ALTER TABLE <TABLE NAME> ADD (<COLUMN NAME1> <DATA
TYPE> <SIZE>,(<COLUMN NAME2> <DATA TYPE> <SIZE>,
………………………………………………………………);
QUERY: 09
REMOVE / DROP
QUERY: 10
Q10. Write a query to drop a column from an existing table employee
Syntax for add a new column:
SQL> ALTER TABLE <TABLE NAME> DROP COLUMN <COLUMN NAME>;
QUERY: 10
Table altered.
SQL> DESC EMP;
Name Null? Type
----------------------------------------- -------- -------------
EMPNO NUMBER(7)
ENAME VARCHAR2(12)
DESIGNATIN VARCHAR2(10)
SALARY NUMBER(8,2)
QUALIFICATION VARCHAR2(6)
DOB DATE
QUERY: 11
Q10. Write a query to drop multiple columns from employee
Syntax for add a new column:
SQL> ALTER TABLE <TABLE NAME> DROP <COLUMN
NAME1>,<COLUMN NAME2>,…...........................................;
QUERY: 11
REMOVE
QUERY: 12
Q10. Write a query to rename table emp to employee
Syntax for add a new column:
SQL> ALTER TABLE RENAME <OLD NAME> TO <NEW NAME>
QUERY: 12
CONSTRAINTS
Constraints are part of the table definition that limits and restriction on the value
entered into its columns.
TYPES OF CONSTRAINTS:
1) Primary key
2) Foreign key/references
3) Check
4) Unique
5) Not null
6) Null
7) Default
OPERATION ON CONSTRAINT:
i) ENABLE
ii) DISABLE
iii) DROP
Q14. Write a query to create primary constraints with column level with naming
convention
QUERY:14
QUERY: 15
SQL>CREATE TABLE EMPLOYEE (EMPNO NUMBER(6),
ENAME VARCHAR2(20),
JOB VARCHAR2(6),
SAL NUMBER(7),
DEPTNO NUMBER(5),
CONSTRAINT EMP_EMPNO_PK PRIMARY
KEY(EMPNO));
QUERY: 16
SQL>CREATE TABLE EMPLOYEE(EMPNO NUMBER(5),
ENAME VARCHAR2(6),
JOB VARCHAR2(6),
SAL NUMBER(6),
DEPTNO NUMBER(6));
SQL>ALTER TABLE EMP3 ADD CONSTRAINT EMP3_EMPNO_PK PRIMARY
KEY (EMPNO);
Q.17. Write a query to create foreign key constraints with column level
Parent Table:
Syntax for Column level constraints Using Primary key:
SQL:>CREATE <OBJ.TYPE> <OBJ.NAME> (COLUMN NAME.1 <DATATYPE>
(SIZE)<TYPE OF CONSTRAINTS> , COLUMN NAME.1 <DATATYPE> (SIZE)
……………………………);
Child Table:
Syntax for Column level constraints Using foreign key:
SQL:>CREATE <OBJ.TYPE> <OBJ.NAME> (COLUMN NAME.1 <DATATYPE>
(SIZE), COLUMN NAME2 <DATATYPE> (SIZE) REFERENCES <TABLE NAME>
(COLUMN NAME>.............................................);
QUERY: 17
SQL>CREATE TABLE DEPT(DEPTNO NUMBER(2) PRIMARY
KEY,
DNAME VARCHAR2(20),
LOCATION VARCHAR2(15));
Parent Table:
Syntax for Column level constraints Using Primary key:
Q.18. Write a query to create foreign key constraints with column level
SQL:>CREATE <OBJ.TYPE> <OBJ.NAME> (COLUMN NAME.1 <DATATYPE>
(SIZE)<TYPE OF CONSTRAINTS> , COLUMN NAME.1 <DATATYPE> (SIZE)
……………………………);
Child Table:
Syntax for Column level constraints using foreign key:
SQL:>CREATE <OBJ.TYPE> <OBJ.NAME> (COLUMN NAME.1 <DATATYPE>
(SIZE) , COLUMN NAME2 <DATATYPE> (SIZE) CONSTRAINT <CONST.
NAME> REFERENCES <TABLE NAME> (COLUMN NAME>
……………………………);
QUERY:18
QUERY: 19
SQL>CREATE TABLE DEPT
(DEPTNO NUMBER(2) PRIMARY KEY,
DNAME VARCHAR2(20),
LOCATION VARCHAR2(15));
Child Table:
Syntax for Table level constraints using foreign key:
SQL:>CREATE <OBJ.TYPE> <OBJ.NAME> (COLUMN NAME.1 <DATATYPE>
(SIZE) , COLUMN NAME2 <DATATYPE> (SIZE));
Check constraint
Column Level Check Constraint
Q.21. Write a query to create Check constraints with column level
Syntax for clumn level constraints using Check:
SQL:>CREATE <OBJ.TYPE> <OBJ.NAME> (COLUMN NAME.1 <DATATYPE>
(SIZE) CONSTRAINT <CONSTRAINTS NAME> <TYPE OF CONSTRAINTS>
(CONSTRAITNS CRITERIA) , COLUMN NAME2 <DATATYPE> (SIZE));
QUERY:21
QUERY:23
SQL>CREATE TABLE EMP9(EMPNO NUMBER,
ENAME VARCHAR2(20),
DESIGN VARCHAR2(15),
SAL NUMBER(5));
Unique Constraint
Column Level
Constraint
Q.24. Write a query to create unique constraints with column level
Syntax for Column level constraints with Unique:
SQL :> CREATE <OBJ.TYPE> <OBJ.NAME> (<COLUMN NAME.1>
<DATATYPE> (SIZE) CONSTRAINT <NAME OF CONSTRAINTS>
<CONSTRAINT TYPE>, (COLUMN NAME2 <DATATYPE> (SIZE)) ;
QUERY:24
QUERY:25
QUERY:26
Not Null
QUERY: 27
SQL>CREATE TABLE EMP13
(EMPNO NUMBER(4),
ENAME VARCHAR2(20) CONSTRAINT EMP13_ENAME_NN NOT NULL,
DESIGN VARCHAR2(20),
SAL NUMBER(3));
Null
Column Level Constraint
Q.28. Write a query to create Null constraints with column level
Syntax for Column level constraints with Null:
SQL :> CREATE <OBJ.TYPE> <OBJ.NAME> (<COLUMN NAME.1>
<DATATYPE> (SIZE) CONSTRAINT <NAME OF CONSTRAINTS>
<CONSTRAINT TYPE>, (COLUMN NAME2 <DATATYPE> (SIZE)) ;
QUERY:28
Constraint Enable
QUERY:29
SQL>ALTER TABLE EMP13 DISABLE CONSTRAINT EMP13_ENAME_NN
NULL;
QUERY:30
SQL>ALTER TABLE EMP13 ENABLE CONSTRAINT EMP13_ENAME_NN
NULL;
EX: NO: 2
Database design using Conceptual modeling (ER-EER) – top-down approach Mapping
conceptual to relational database and validate using Normalization
AIM:
To execute and verify the DML and TCL Language commands
STEP 1: Start
STEP 2: Create the table with its essential attributes.
STEP 3: Insert the record into table
STEP 4: Update the existing records into the table
STEP 5: Delete the records in to the table
STEP 6: use save point if any changes occur in any portion of the record to undo its
original state.
STEP 7: use rollback for completely undo the records
STEP 6: use commit for permanently save the records.
SQL COMMANDS
1. COMMAND NAME: INSERT
COMMAND DESCRIPTION: INSERT command is used to Insert objects
in the database.
2. COMMAND NAME: SELECT
COMMAND DESCRIPTION: SELECT command is used to SELECT the object from
the database.
3. COMMAND NAME: UPDATE
COMMAND DESCRIPTION: UPDATE command is used to UPDATE
the records from the table
4. COMMAND NAME: DELETE
COMMAND DESCRIPTION: DELETE command is used to DELETE the
Records form the table
5. COMMAND NAME: COMMIT
COMMAND DESCRIPTION: COMMIT command is used to save the
Records.
INSERT
QUERY: 01
QUERY: 01
INSERT A RECORD FROM AN EXISTING TABLE:
SQL>INSERT INTO EMP VALUES(101,'NAGARAJAN','LECTURER',15000);
1 row created.
SELECT
QUERY: 02
QUERY: 02
DISPLAY THE EMP TABLE:
SQL> SELECT * FROM EMP;
QUERY: 03
Q3. Write a query to insert the records in to employee using substitution method.
Syntax for Insert Records into the table:
SQL :> INSERT INTO <TABLE NAME> VALUES< ‘&column name’, ‘&column
name 2’,…..);
QUERY: 03
SQL> INSERT INTO EMP
VALUES(&EMPNO,'&ENAME','&DESIGNATIN','&SALARY');
Enter value for empno: 102
Enter value for ename: SARAVANAN
Enter value for designatin: LECTURER
Enter value for salary: 15000
old 1: INSERT INTO EMP
VALUES(&EMPNO,'&ENAME','&DESIGNATIN','&SALARY')
new 1: INSERT INTO EMP VALUES(102,'SARAVANAN','LECTURER','15000')
1 row created.
SQL> /
Enter value for empno: 103
Enter value for ename: PANNERSELVAM
Enter value for designatin: ASST. PROF
Enter value for salary: 20000
old 1: INSERT INTO EMP
VALUES(&EMPNO,'&ENAME','&DESIGNATIN','&SALARY')
new 1: INSERT INTO EMP VALUES(103,'PANNERSELVAM','ASST.
PROF','20000')
1 row created.
SQL> /
Enter value for empno: 104
Enter value for ename: CHINNI
Enter value for designatin: HOD, PROF
Enter value for salary: 45000
old 1: INSERT INTO EMP
VALUES(&EMPNO,'&ENAME','&DESIGNATIN','&SALARY')
new 1: INSERT INTO EMP VALUES(104,'CHINNI','HOD, PROF','45000')
1 row created.
SQL> SELECT * FROM EMP;
QUERY: 04
QUERY: 05
SQL>UPDATE EMP SET SALARY = 16000, DESIGNATIN='ASST. PROF' WHERE
EMPNO=102;
1 row updated.
SQL> SELECT * FROM EMP;
DELETE
QUERY: 06
QUERY: 06
SAVEPOINT:
QUERY: 07
QUERY: 07
Savepoint created.
ROLL BACK
QUERY: 08
QUERY: 08
COMMIT
QUERY: 09
SQL> COMMIT;
QUERY: 09
SQL> COMMIT;
Commit complete.
SQL>CONNECT SYSTEM/MANAGER;
SQL>CONNECT "USERNAME"/"PASSWORD";
EXAMPLE
CREATING A USER
SQL>CONNECT SYSTEM/MANAGER;
SQL>CONNECT CSE2/CSECSE;
6 rows selected.
10 rows selected.
9 rows selected.
14 rows selected.
14 rows selected.
EX: NO: 3 Implement the database using SQL Data definition with
constraints, Views
AIM
OBJECTIVE:
Nested Query can have more than one level of nesting in one single query. A SQL nested
query is a SELECT query that is nested inside a SELECT, UPDATE, INSERT, or DELETE
SQL query.
PROCEDURE
STEP 1: Start
STEP 4: Create the Nested query from the above created table.
STEP 6: Stop
SQL COMMANDS
COMMAND DESCRIPTION: SELECT command is used to select records from the table.
Table -1
SYNTAX FOR CREATING A TABLE:
INSERTION
SQL> INSERT INTO EMP2 VALUES(1001,'MAHESH','PROGRAMMER',15000,1560,200);
1 ROW CREATED.
SQL> INSERT INTO EMP2 VALUES(1002,'MANOJ','TESTER',12000,1560,200);
1 ROW CREATED.
SQL> INSERT INTO EMP2 VALUES(1003,'KARTHIK','PROGRAMMER',13000,1400,201);
1 ROW CREATED.
SQL> INSERT INTO EMP2 VALUES(1004,'NARESH','CLERK',1400,1400,201);
1 ROW CREATED.
SQL> INSERT INTO EMP2 VALUES(1005,'MANI','TESTER',13000,1400,200);
1 ROW CREATED.
SQL> INSERT INTO EMP2 VALUES(1006,'VIKI','DESIGNER',12500,1560,201);
1 ROW CREATED.
SQL> INSERT INTO EMP2 VALUES(1007,'MOHAN','DESIGNER',14000,1560,201);
1 ROW CREATED.
SQL> INSERT INTO EMP2 VALUES(1008,'NAVEEN','CREATION',20000,1400,201);
1 ROW CREATED.
SQL> INSERT INTO EMP2 VALUES(1009,'PRASAD','DIR',20000,1560,202);
1 ROW CREATED.
SQL> INSERT INTO EMP2 VALUES(1010,'AGNESH','DIR',15000,1400,200);
1 ROW CREATED.
TABLE- 2
SYNTAX FOR CREATING A TABLE:
INSERTION
SQL> INSERT INTO DEPT2 VALUES(107,'DEVELOP','ADYAR');
1 ROW CREATED.
SQL> INSERT INTO DEPT2 VALUES(201,'DEBUG','UK');
1 ROW CREATED.
SQL> INSERT INTO DEPT2 VALUES(200,'TEST','US');
SQL> INSERT INTO DEPT2 VALUES(201,'TEST','USSR');
1 ROW CREATED.
SQL> INSERT INTO DEPT2 VALUES(108,'DEBUG','ADYAR');
1 ROW CREATED.
SQL> INSERT INTO DEPT2 VALUES(109,'BUILD','POTHERI');
1 ROW CREATED.
SELECT "COLUMN_NAME1"
FROM "TABLE_NAME1"
WHERE "COLUMN_NAME2" [COMPARISON OPERATOR]
(SELECT "COLUMN_NAME3"
FROM "TABLE_NAME2"
WHERE [CONDITION])
ENAME
MAHESH
MANOJ
KARTHIK
MANI
VIKI
MOHAN
NAVEEN
PRASAD
AGNESH
EX: NO: 4 Query the database using SQL Manipulation
AIM
OBJECTIVE:
Views Helps to encapsulate complex query and make it reusable.
Provides user security on each view - it depends on your data policy security.
Using view to convert units - if you have a financial data in US currency, you can
create view to convert them into Euro for viewing in Euro currency.
PROCEDURE
STEP 1: Start
STEP 5: Execute different Commands and extract information from the View.
STEP 6: Stop
.SQL COMMANDS
COMMAND DESCRIPTION: INSERT command is used to insert a new row into the view.
COMMAND DESCRIPTION: DELETE command is used to delete a row from the view.
CREATION OF TABLE
--------------------------------
Table created.
TABLE DESCRIPTION
EMPLOYEE_NAME VARCHAR2(10)
EMPLOYEE_NO NUMBER(8)
DEPT_NAME VARCHAR2(10)
DEPT_NO NUMBER(5)
DATE_OF_JOIN DATE
CREATION OF VIEW
VIEW CREATED.
DESCRIPTION OF VIEW
EMPLOYEE_NAME VARCHAR2(10)
EMPLOYEE_NO NUMBER(8)
DEPT_NAME VARCHAR2(10)
DEPT_NO NUMBER(5)
DISPLAY VIEW:
----------------------
INSERT STATEMENT:
SYNTAX:
SQL> INSERT INTO <VIEW_NAME> (COLUMN NAME1,………)
VALUES(VALUE1,….);
1 ROW CREATED.
DELETION OF VIEW:
DELETE STATEMENT:
SYNTAX:
SQL> DELETE <VIEW_NMAE>WHERE <COLUMN NMAE> =’VALUE’;
UPDATE STATEMENT:
SYNTAX:
AQL>UPDATE <VIEW_NAME> SET< COLUMN NAME> = <COLUMN NAME>
+<VIEW> WHERE <COLUMNNAME>=VALUE;
1 ROW UPDATED.
DROP A VIEW:
SYNTAX:
SQL> DROP VIEW <VIEW_NAME>
EXAMPLE
VIEW DROPED
EXAMPLE-2:
SQL> CREATE OR REPLACE VIEW EMPL_VIEW1 AS SELECT EMPNO, ENAME,
SALARY FROM EMPL;
SQL> SELECT * FROM EMPL_VIEW1;
EXAMPLE-3:
SQL> CREATE OR REPLACE VIEW EMPL_VIEW2 AS SELECT * FROM EMPL WHERE
DEPTNO=10;
Note:
Replace is the keyboard to avoid the error “ora_0095:name is already used by an existing
abject”.
View created.
View created.
TYPE-2:
SQL> CREATE OR REPLACE VIEW EMP_TOTSAL AS SELECT EMPNO "EID",ENAME
"NAME",SALARY "SAL" FROM EMPL;
View created.
View created.
EXAMPLE-4:
SQL> CREATE OR REPLACE VIEW EMP_CK_OPTION AS SELECT
EMPNO,ENAME,SALARY,DEPTNO FROM EMPL WHERE DEPTNO
=10 WITH CHECK OPTION;
JOIN VIEW:
EXAMPLE-5:
SQL> CREATE OR REPLACE VIEW DEPT_EMP_VIEW AS SELECT A.EMPNO,
A.ENAME, A.DEPTNO, B.DNAME, B.LOC FROM EMPL
A,DEPMT B WHERE A.DEPTNO=B.DEPTNO;
View created.
FORCE VIEW
EXAMPLE-6:
SQL> CREATE OR REPLACE FORCE VIEW MYVIEW AS SELECT * FROM XYZ;
Table created.
View created.
COMPILING A VIEW
SYNTAX:
ALTER VIEW <VIEW_NAME> COMPILE;
EXAMPLE:
SQL> ALTER VIEW MYVIEW COMPILE;
RESULT: Thus the SQL commands for View has been verified and executed successfully.
EX: NO: 5 Querying/Managing the database using SQL Programming - Stored
Procedures/Functions - Constraints and security using Triggers
AIM
To write a PL/SQL block using different control (if, if else, for loop, while loop,…)
statements.
OBJECTIVE:
PL/SQL Control Structure provides conditional tests, loops, flow control and branches that
PROCEDURE
STEP 1: Start
STEP 3: Develop the set of statements with the essential operational parameters.
STEP 6: Stop.
SQL> DECLARE
<VARIABLE DECLARATION>;
BEGIN
END;
PL/SQL CODING FOR ADDITION OF TWO NUMBERS
SQL> declare
a number;
b number;
c number;
begin
a:=&a;
b:=&b;
c:=a+b;
dbms_output.put_line('sum of'||a||'and'||b||'is'||c);
end;
/
INPUT:
OUTPUT:
sum of23and12is35
PROCEDURE
STEP 1: Start
STEP 5: Stop.
SQL> DECLARE
<VARIABLE DECLARATION>;
BEGIN
IF(CONDITION)THEN
<EXECUTABLE STATEMENT >;
END;
DECLARE
b number;
c number;
BEGIN
B:=10;
C:=20;
if(C>B) THEN
dbms_output.put_line('C is maximum');
end if;
end;
/
OUTPUT:
C is maximum
SQL> DECLARE
<VARIABLE DECLARATION>;
BEGIN
IF (TEST CONDITION) THEN
<STATEMENTS>;
ELSE
<STATEMENTS>;
ENDIF;
END;
SQL> declare
n number;
begin
dbms_output. put_line('enter a number');
n:=&number;
if n<5 then
dbms_output.put_line('entered number is less than 5');
else
dbms_output.put_line('entered number is greater than 5');
end if;
end;
/
Input
Enter value for number: 2
old 5: n:=&number;
new 5: n:=2;
Output:
entered number is less than 5
SQL> DECLARE
<VARIABLE DECLARATION>;
BEGIN
IF (TEST CONDITION) THEN
<STATEMENTS>;
ELSEIF (TEST CONDITION) THEN
<STATEMENTS>;
ELSE
<STATEMENTS>;
ENDIF;
END;
********** GREATEST OF THREE NUMBERS USING IF ELSEIF************
SQL> declare
a number;
b number;
c number;
d number;
begin
a:=&a;
b:=&b;
c:=&b;
if(a>b)and(a>c) then
dbms_output.put_line('A is maximum');
elsif(b>a)and(b>c)then
dbms_output.put_line('B is maximum');
else
dbms_output.put_line('C is maximum');
end if;
end;
/
INPUT:
OUTPUT:
C is maximum
SQL> DECLARE
<VARIABLE DECLARATION>;
BEGIN
LOOP
<STATEMENT>;
END LOOP;
<EXECUTAVLE STATEMENT>;
END;
SQL> declare
n number;
sum1 number default 0;
endvalue number;
begin
endvalue:=&endvalue;
n:=1;
for n in 1..endvalue
loop
if mod(n,2)=1
then
sum1:=sum1+n;
end if;
end loop;
dbms_output.put_line('sum ='||sum1);
end;
/
INPUT:
sum =4
SQL> DECLARE
<VARIABLE DECLARATION>;
BEGIN
WHILE <condition>
LOOP
<STATEMENT>;
END LOOP;
<EXECUTAVLE STATEMENT>;
END;
SQL> declare
n number;
sum1 number default 0;
endvalue number;
begin
endvalue:=&endvalue;
n:=1;
while(n<endvalue)
loop
sum1:=sum1+n;
n:=n+2;
end loop;
dbms_output.put_line('sum of odd no. bt 1 and' ||endvalue||'is'||sum1);
end;
/
INPUT:
OUTPUT:
RESULT:
Thus the PL/SQL block for different controls are verified and executed.
EX:NO:6 Database design using Normalization – bottom-up approach
AIM
PROCEDURE
STEP 1: Start
STEP 6: Stop
CODING:
End Sub
End Sub
To design a Single Document Interface and Multiple Document Interface forms using
Visual Basic.
PROCEDURE
STEP 1: Start
STEP 6: Stop
EXECUTION
SDI MENU:
SDI ADDITION:
SDI DIVISION
SDI MULTIPLICATION
SDI SUBRACTION
MDI MENU:
MDI ADD:
MDI MUL:
MDI DIV
MDI SUB
RESULT: Thus the program has been loaded and executed successfully.
EX: NO: 8 Database design using EER-to-ODB mapping / UML class
diagrams
AIM
To develop and execute a Trigger for Before and After update, Delete, Insert operations on a
table.
PROCEDURE
STEP 1: Start
STEP 3:Specify the operations (update, delete, insert) for which the trigger has to be
executed.
STEP 4: Execute the Trigger procedure for both Before and After sequences
STEP 5: Carryout the operation on the table to check for Trigger execution.
STEP 6: Stop
EXECUTION
1. Create a Trigger to pop-up the DML operations
Table created.
1 row created.
1 row created.
SQL> select * from empa;
Trigger created.
1 row created.
1 row updated.
1 row deleted.
2. Create a Trigger to check the age valid or not Using Message Alert
Table created.
PROGRAM:
Trigger created.
NAME AGE
abc 15
xyz -12
3. Create a Trigger to check the age valid and Raise appropriate error code and
error message.
NAME AGE
abc 10
4. Create a Trigger for EMP table it will update another table SALARY while
inserting values.
1 row created.
1 row created.
1 row created.
VEC 1 1000
SRM 0 0
1 row created.
VEC 1 1000
SRM 1 3000
VEC 2 6000
SRM 1 3000
1 row created.
VEC 3 8000
SRM 1 3000
1 row created.
VEC 3 8000
SRM 2 11000
RESULT: Thus the Trigger procedure has been executed successfully for both before
and after sequences.
EX:NO:9 Object features of SQL-UDTs and sub-types, Tables using UDTs,
Inheritance, Method definition
AIM
PROCEDURE
STEP 1: Start
STEP 2: Create the form with essential controls and insert the menu using menu editor.
STEP 6: Stop
EXECUTION
Coding:
Private Sub ab_Click()
RichTextBox1.SelFontName = "Arial Black"
End Sub
End Sub
File Menu:
Edit Menu
Format Menu:
Fig.3. Format Menu
RESULT: Thus the program has been loaded and executed successfully.
EX: NO: 10 Querying the Object-relational database using Objet Query
language
AIM
PROCEDURE
STEP 1: Start
STEP 2: Create the form with essential controls and insert the menu using menu editor.
STEP 6: Stop
EXECUTION
Unload Me
End Sub
Unload Me
frmLogin.Show
End Sub
ProgressBar1.Value = ProgressBar1.Value + 1
Unload Me
End If
End Sub
ProgressBar2.Value = ProgressBar2.Value + 1
MsgBox ("welcome")
login.Show
Unload Me
End If
End Sub
Unload Me
Stock.Show
Else
End If
End Sub
End
End Sub
frmDataEnv.Show
Unload Me
End If
End Sub
Stock Form:
Adodc1.Recordset.AddNew
Text1.Text = a
Text3.Text = C
D = InputBox("ENTER SUPPLIER")
Text4.Text = D
Text5.Text = e
Text6.Text = F
Text7.Text = G
Text8.Text = H
Text8.Text = Val(Text7.Text) / 14
Text9.SetFocus
'Adodc1.Recordset.Save
'MsgBox ("UPDATED")
End Sub
Dim s As String
a = Trim(a)
s = "product_TNAME='" & a '" "
Adodc1.Recordset.Delete
MsgBox ("deleted")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
End Sub
Adodc1.Recordset.MoveNext
End Sub
'dodc1.Recordset.MoveNext
Adodc1.Recordset.MoveNext
Else
Adodc1.Recordset.MovePrevious
End If
End Sub
'dodc1.Recordset.MovePrevious
Adodc1.Recordset.MoveFirst
Else '
Adodc1.Recordset.MoveNext
End If
End Sub
Dim a As String
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find s
If Adodc1.Recordset.EOF Then
MsgBox ("INVALID RECORD")
End If
End Sub
Adodc1.Recordset.Update
MsgBox ("UPDATED")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
End Sub
Adodc1.Recordset.MoveFirst
End Sub
Dim a As String
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find s
'Adodc1.Recordset ("select * from t1 where [ITEM_CODE] = " & Text1.Text(0) & "")
DataReport1.Show
If Adodc1.Recordset.EOF Then
End If
End Sub
Adodc1.Recordset.Update
End Sub
Dim s As String
a = Trim(a)
Adodc1.Recordset.Delete
MsgBox ("deleted")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
End Sub
DataReport1.Show
End Sub
End
End Sub
'Adodc1.Recordset (" * from t1 where [ITEM_CODE] = " & Text1.Text(0) & "")
DataReport1.Show
End Sub
'Adodc2.Refresh
End Sub
DataReport1.Show
End Sub
Output:
Progress Bar
Login
Stock Form:
Report Design:
RESULT: Thus the program has been loaded and executed successfully.
.