0% found this document useful (0 votes)
496 views56 pages

Ad3381 - Data Base Design and Management Manual

Uploaded by

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

Ad3381 - Data Base Design and Management Manual

Uploaded by

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

EX NO: 1 Database Development Life cycle: Problem definition and

Requirement analysis Scope and Constraints

AIM:
To execute and verify Database Development Life cycle: Problem definition and
Requirement analysis Scope and Constraints

PROCEDURE:

STEP 1: Start

STEP 2: Create the table with its essential attributes.

STEP 3: Execute different Commands and extract information from the table.

STEP 4: Stop

CREATE

Creating a Database
Syntax : CREATE DATABASE <DB_NAME>;
Example : CREATE DATABASE Test;

Creating a Table
Command : CREATE

Purpose : To create objects in the database

Syntax : CREATE TABLE table_name (column_name1

data_type,column_name2 data_type, column_name3

data_type,...);

Example : create table emp11(emp_namevarchar(20),emp_phone

number(10),emp_addr varchar(30));

Sample output: Table created.


1. ALTER

Command : ALTER

Purpose : Alters the structure of the

database Syntax :

i) To add a column in a table


Sample output: Table altered.

2. RENAME

Command : RENAME

Purpose : Rename an object

Syntax : RENAME old_table_name to new_table_name;

Example : rename emp11 to emp123;

Sample output : Table renamed.

3. DESCRIBE

Command : DESCRIBE

Purpose : Describes the structure of the table

Syntax : Desc table_name;

Example : desc

emp11; Sample output:

Name Null? Type

EMP_NAME VARCHAR2(20)

EMP_PHONE NUMBER(10)

EMP_ADDR VARCHAR2(30)

EMP_ID NUMBER(10)
EMP_SALARY NUMBER(10)

4. DROP

Command : DROP

Purpose : Delete objects from the database

Syntax : DROP TABLE table_name;

Example : drop table emp123

TRUNCATE

Command : TRUNCATE

Purpose : Remove all records from a table, including all spaces

allocated for the records are removed

Syntax : TRUNCATE TABLE table_name;

Example : truncate table emp123;

Sample output : Table truncated.

2. INSERT
Command : INSERT

Purpose : Insert data into a

table. Syntax :

i) To insert one row at at time

INSERT INTO table_name VALUES (value1, value2,

value3,...); Example : insert into

emp123values('Ram',9787563641,'India'); Sample output:

1 row created.
To insert many rows at a time

INSERT INTO table_name values (&column1,&column2,….);

Example : insert into

emp123values('&emp_name','&emp_phone','&emp_addr'); Enter

value for emp_name: Joseph

Enter value for emp_phone:

9787654123 Enter value for

emp_addr: Tamilnadu

old 1: insert into emp123 values('&emp_name','&emp_phone','&emp_addr')

new 1: insert into emp123

values('Joseph','9787654123','Tamilnadu') Sample output: 1 row

created.

ii) Inserting Data’s in specified columns:

INSERT INTO table_name(col1,col2,…….,coln)


VALUES(val1,val2,……,valn);
2. UPDATE

Command : UPDATE

Purpose : Updates existing data within a table.

Syntax : UPDATE table_name SET column1=value, column2=value2,...

WHERE (condition);

Example : update emp123 set emp_id=40 where

emp_addr='Tamilnadu'; Sample output: 1 row updated.


3. DELETE

Command : DELETE

Purpose : Deletes all records from a table, the space for the

records remain. Syntax : DELETE FROM table_name WHERE

(condition);

Example : delete from emp123 where

emp_id=30; Sample output : 1 row deleted.

3. SELECT

Command : SELECT

Purpose : fetch the data from a table which returns data in

the table. Syntax : SELECT column1, column2, columnN

FROM table_name; Example1 : Select * from customers;

Sample output:

+ + + + + +

| ID | NAME | AGE | ADDRESS | SALARY |


+ + + + + +
| 1 | Ramesh | 32 |Ahmedabad | 2000.00 |
| 2 | Khilan | 25 | Delhi | 1500.00 |
| 3 | kaushik | 23 | Kota | 2000.00 |
| 4 | Chaitali| 25 | Mumbai | 6500.00 |
+ + + + + +
Example2 : Select id, name, salary from

customers; Sample output:

+ + + +
| ID | NAME| SALARY |
+ + + +
| 1 | Ramesh | 2000.00 |
| 2 | Khilan | 1500.00 |
| 3 | kaushik | 2000.00 |
| 4 | Chaitali| 6500.00 |
1. Group by

Command : GROUP BY

Purpose : Group the collection of values based on an object.

Syntax : select obj.name/col. Name sum () / count ()…. from

table_name group by (obj.name/col.name);

Example : select rollno, sum (hscmarks) from student group by

(rollnumber); Sample output:

+ + +
| rollno | SUM(HSCMARKS) |
+ + +

| 45 | 34 |
| 56 | 30 |
| 89 | 56 |

+ + +

2. Having clause

Command : HAVING

Purpose : Filters the data on the group row but not on the

individual row. Syntax :


SELECT column_name(s)
FROM table_name WHERE
condition
GROUP BY column_name(s)
HAVING condition
ORDER BY column_name(s);

Example : select rollnumber,sum((hscmarks*.30)+hscmarks)

from student group by(rollnumber) having

sum(hscmarks)<50;

Sample output:

ROLLNUMBER SUM((HSCMARKS*.30)+HSCMARKS)

1 15.6
45 44.2
56 39

RESULT:

Thus The SQL Comment Was Successfully Executed.


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 Database design using Conceptual modeling (ER-EER) – top-
down approach Mapping conceptual to relational database and validate using Normalization

PROCEDURE:

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.

The Following are the entities:

1 .Bus

2. Reservation
3. Ticket
4. Passenger
5. Cancellation
The attributes in the Entities:
Bus:( Entity)

Passenger:

The attributes in the Entities:


Bus:( Entity)
Ticket :(Entity)

Passenger:
Cancellation (Entity)
Concept design with E-R Model:

RESULT:

Thus The SQL Comment Was Successfully Executed.


EX.NO: 3 Implement The Database Using Sql Data Definition With
Constraints, Views

AIM:
To execute and verify the Implement the database using SQL Data definition with
constraints, Views

PROCEDURE

STEP 1: Start

STEP 2: Create two different tables with its essential attributes.

STEP 3: Insert attribute values into the table.

STEP 4: Create the Nested query from the above created table.

STEP 5: Execute Command and extract information from the

tables. STEP 6: Stop

VIEWS

1. Create Views
Syntax:

CREATE VIEW view_name AS SELECT


column1, column2... FROM table_name
WHERE [condition];

Example:

Consider the CUSTOMERS table


+ + + + + +

| ID | NAME | AGE | ADDRESS | SALARY |

+ + + + + +
| 1 | Ramesh | 32 | Ahmedaba | 2000.00 |
d
| 2 | Khilan | 25 | Delhi | 1500.00 |
| 3 | kaushik | 23 | Kota | 2000.00 |
| 4 | Chaitali | 25 | Mumbai | 6500.0 |
0
| 5 | Hardik | 27 | Bhopal | 8500.0 |
0
| 6 | Komal | 22 | MP | 4500.0 |
0
| 7 | Muffy | 24 | Indore | 10000.0 |
0
+ + + + + +

Mysql > create view customers_view as select name, age from customers;
Sample Output: View created.

2. Select Views
Select ALL columns from View

Mysql > select * from customers_view;


Sample Output:
+ + +

| name | age |

+ + +

| Ramesh | 32 |
| Khilan | 25 |
| kaushik | 23 |

| Chaitali | 25 |
| Hardik | 27 |
| Komal | 22 |
| Muffy | 24 |
increment_value: Value by which sequence will increment

itself. minimum_value: Minimum value of the sequence.

maximum_value: Maximum value of the sequence.

Cycle : When sequence reaches its set_limit it starts from beginning.

Nocycle : An exception will be thrown if sequence exceeds its


max_value.
+ + +

SELECT SPECIFIED COLUMNS FROM VIEW

Mysql > select name from customers_view where age=32;


+ + +

| name | age |

+ + +

| Ramesh | 32 |

+ + +

1. DROP VIEW:
Purpose: To delete the table

Syntax: Drop view

View_name ;

Example: MYSQL> drop view

customers_view ; Sample output: View

dropped.
SEQUENCES
1. Creating Sequences
Syntax:

CREATE SEQUENCE sequence_name START WITH

initial_value INCREMENT BY increment_value

MINVALUE minimum value MAXVALUE maximum

value CYCLE|NOCYCLE ;

Where,
sequence_name: Name of the sequence.

initial_value : Starting value from where the sequence starts.

Initial_value >= minimum value and <= maximum value.

increment_value: Value by which sequence will

increment itself. minimum_value: Minimum value of

the sequence. maximum_value: Maximum value of the

sequence.

Cycle : When sequence reaches its set_limit it starts from beginning.

Nocycle : An exception will be thrown if sequence exceeds its


max_value.
Example:
CREATE SEQUENCE

sequence_1 start with 1

increment by 1

minvalue 0

maxvalue

100 cycle;

Example to use sequence :

CREATE TABLE students( ID number(10),NAME

char(20)); INSERT into students

VALUES(sequence_1.nextval,'Ramesh'); INSERT

into students VALUES(sequence_1.nextval,'Suresh');

Output:
| ID | NAME |

| 1 | Ramesh |
| 2 | Suresh

SYNONYM
1. Creating Sequences
CREATE [OR REPLACE] [PUBLIC] SYNONYM [schema .]
synonym_name FOR [schema .] object_name [@ dblink];
Example:

CREATE OR REPLACE PUBLIC SYNONYM suppliers FOR


app.suppliers;

2. Drop synonym
DROP [PUBLIC] SYNONYM [schema .] synonym_name [force];

Example:

Drop public synonym suppliers;

RESULT:

Thus The SQL Comment Was Successfully Executed.


EX: NO: Query the database using SQL Manipulation

AIM:

To execute and verify the Query the database using SQL Manipulation

PROCEDURE:

STEP 1: Start

STEP 2: Create the table with its essential

attributes. STEP 3: Insert attribute values into

the table.

STEP 4: Create the view from the above created table.

STEP 5: Execute different Commands and extract information

from the View. STEP 6: Stop

SQL> select * from student;

ID NAME DEP PERCENT M2 M3 TOT G


M1
1 Anu it 0 90 89 80 0
2 Beena cse 0 98 91 95 0
3 Bindhu it 0 87 67 86 0
4 Varun it 0 67 46 50 0
5 Rahul cse 0 81 82 83 0
SQL> declare

2 cursor c is select * from student;


3 ctot number;
4 cgra varchar2(1);
5 cper number;
6 begin
7 for I in c
8 loop
9 ctot= i.m1+i.m2+i.m3;
10 cper :=ctot/3;
11 update student set tot = ctot where id =i.id;
12 update student set percent = cper where id =i.id;
13 if(cper between 91 and 100)then
14 cgra:= ‘S’
15 elsif(cper between 81 and 90)then
16 cgra:= ‘A’
17 elsif(cper between 71 and 80) elsif(cper between 61 and 70)then
18 cgra:= ‘C’
19 elsif(cper between 56 and 60)then
20 cgra:= ‘D’
21 elsif(cper between 50 and 55)then
22 cgra:= ‘E’
23 else
24 cgra:= ‘F’
25 end if;
26 update student set g = cgra where id =i.id;
27 end loop;
28 end;
31 /
PL/ SQL procedure successfully completed.

SQL> select * from student;

ID NAME DEP PERCENT M2 M3 TOT

Anu it 86.3333333 989 80 259

Beena cse 94.6666667 91 95 284

Bindhu it 867 86 240

Varun it 54.3333333 646 50 163

Rahul cse 8 246

Select * from customers;

+ + + + + +

| ID | NAME | AGE | ADDRESS | SALARY |

+ + + + + +
| Ramesh | Ahmedabad
3 20

| Khilan | Delhi
2 15

| kaushik | Kota
2 20

| Chaitali | Mumbai
2 65

| Hardik | Bhopal
2 85

| Komal | 2 45

+ + + + + +
RESULT:

Thus The SQL Comment Was Successfully Executed.


EX: NO: 5 Querying/Managing the database using SQL Programming -
Stored Procedures/Functions - Constraints and security using Triggers

AIM:
To write a Querying/Managing the database using SQL Programming -
Stored Procedures/Functions - Constraints and security using Triggers

PROCEDURE:

STEP 1: Start

STEP 2: Initialize the necessary variables.

STEP 3: Develop the set of statements with the essential operational

parameters.

STEP 4: Specify the Individual operation to be carried out.

STEP 5: Execute the statements.

STEP 6: Stop.

SYNTAX:

cursor cursor_name is select * from table

name; To open the cursor:

open

cursor_name;

To close the

cursor:

close cursor_name;
Exercise:

Write PL/ SQL code for calculating hra , da, netsalary for all the employees in the
Payroll Processing using Explicit cursor(uses employee table).

SQL> select * from employee;

EMPNO NAME HRADA PF NETSAL BASIC


P
A
Y
101 AAA 0 0 0 15000
102 BBB 0 0 0 18000
103 CCC 0 0 0 20000
104 DDD 0 0 0 10000
105 EEE 0 0 25000

SQL> declare

2 cursor c is select * from employee;


3 i employee% rowtype;
4 hrasal number;
5 dasal number;
6 pfsal number;
7 netsalary number;
8 begin
9 open c;
10 loop;
11 fetch c into i;
12 if c% notfound ten exit;
13 endif;
14 hrasal:=i.basicpay*0.1;
15 dasal:=i.basicpay*0.08;
16 pfsal:=i.basicpay*0.12;
17 netsalaray:= i.basicpay + hrasal + dasal + pfsal;
18 update employee set hra = hrasal, da= dasal, pf= pfsal, netsal=
netsalaray where empno=i.empno;
19 end loop;
20 close c;
21 end;
22 /
PL/ SQL procedure successfully completed.

22

SQL> select * from employee;

EMPNO NAME HRA DA PF NETSAL BASICPAY

101 AAA 1500 1800


1 15900 15000

102 BBB 1800 1440 2160 19080 18000


103 CCC 2000 2400
1 21200 20000

104 DDD 1000 1200


8 10600 10000

105 EEE 2500 2000 3000 26500 25000

RESULT:
Thus The SQL Comment Was Successfully Executed.
EX:NO:6
DATE: Database design using Normalization – bottom-up approach

AIM:

To design a form using Database design using Normalization – bottom-up


approach.

ALGORITHM:

STEP 1: Start

STEP 2: Create the form with essential controls in tool

box.

STEP 3: Write the code for doing the appropriate

functions.

STEP 4: Save the forms and project.

STEP 5: Execute the form .

STEP 6: Stop.

PROCEDURE:

Normalization is the branch of relational theory that provides design insights.


It is the process of determining how much
redundancy exists in a table. The goals of normalization are to:

Be able to characterize the level of redundancy in a relational schema


Provide mechanisms for transforming schemas in order to remove redundancy

Normal Description
Form

1NF A relation is in 1NF if it contains an atomic value.

2NF A relation will be in 2NF if it is in 1NF and all non-key


attributes are fully functional dependent on the primary
key.

3NF A relation will be in 3NF if it is in 2NF and no transition


dependency exists.

BCNF A stronger definition of 3NF is known as Boyce Codd's


normal form.

4NF A relation will be in 4NF if it is in Boyce Codd's normal


form and has no multi-valued dependency.

5NF A relation is in 5NF. If it is in 4NF and does not contain


any join dependency, joining should be lossless.

Following are the various types of Normal forms:


Example of Second Normal Form (2NF)
employee_roles Table
EMPLOYEE_ID JOB_CODE
E001 J01
E001 J02
E002 J02
E002 J03
E003 J01
employees Table
EMPLOYEE_ID NAME STATE_CODE HOME_STATE
E001 Alice 26 Michigan
E002 Bob 56 Wyoming
E003 Alice 56 Wyoming
jobs table
JOB_CODEJOB
J01 Chef
JOB_CODEJOB
Waite
J02 r
Barte
J03 nder
home_state is now dependent on state_code. So, if you know the state_code, then you
can find the home_state value.
To take this a step further, we should separate them again to a different table to make
it 3NF.

Example of Third Normal Form (3NF)


Employee_roles Table
EMPLOYEE_ID JOB_CODE
E001 J01
E001 J02
E002 J02
E002 J03
E003 J01
Employees Table
EMPLOYE NA STATE_C
E_ID ME ODE
Alic
E001 e 26
E002 Bob 56
Alic
E003 e 56

jobs Table
JOB_CODE JOB
J01 Chef
J02 Waiter
J03 Bartender
states Table
STATE_CODE HOME_STATE
26 Michigan
56 Wyoming
Now our database is in 3NF.

RESULT:

Thus The SQL Comment Was Successfully Executed.


EX.NO:7 Develop database applications using IDE/RAD tools (Eg.,
NetBeans,VisualStudio)
AIM:

To design a Single Develop database applications using IDE/RAD tools (Eg.


NetBeans,VisualStudio)

PROCEDURE

STEP 1: Start

STEP 2: Create the form with essential controls in tool box.

STEP 3: Write the code for doing the appropriate functions.

STEP 4: Save the forms and project.

STEP 5: Execute the form.

TEP 6: Stop

CUSTOMERS table:

NAME AGE ADDRESS SALARY


Alive Khammam 2000
Bob Kadappa 3000
Catri Guntur 4000
Dena Hyderabad 5000
Eeshwar Kurnool 6000
Farooq Nellur 7000

CREATE OR REPLACE TRIGGER display_salary_changes BEFORE DELETE OR INSERT


ORUPDATE ON customers FOR EACH ROW

WHEN (NEW.ID > 0) DECLARE


sal_diff number; BEGIN
sal_diff := :NEW .salary - :OLD .salary; dbms_output.put_line('Old salary: ' || :OLD.salary);
dbms_output.put_line('New salary: ' || :NEW.salary); dbms_output.put_line('Salary
difference: '
|| sal_diff);
END;
/

Here following two points are important and should be noted carefully:

OLD and NEW references are not available for table level triggers, rather you can use
them for record leveltriggers.

If you want to query the table in the same trigger, then you should use the
AFTER keyword, because triggers can query the table or change it again
only after the initial changes are applied and the table is back in a
consistent state.

Above trigger has been written in such a way that it will fire before any
DELETE or INSERT or UPDATE operation on the table, but you can
write your trigger on a single or multiple operations, for example
BEFORE DELETE, which will fire whenever a

record will be deleted using DELETE operation on the table.

Let us perform some DML operations on the CUSTOMERS table. Here is one
INSERT statement, which will create a new record in the table:
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (7, 'Kriti', 22,'HP', 7500.00 );

When a record is created in CUSTOMERS table, above create trigger


display_salary_changeswill be fired and it will display the following result:

Old salary:
New salary: 7500 Salary difference:

SQL> create table Employee(


1 ID VARCHAR2(4 BYTE) NOTNULL,
2 First_Name VARCHAR2(10BYTE),
3 Last_Name VARCHAR2(10BYTE),
4 Start_Date DATE,
5 End_Date DATE,
6 Salary NUMBER(8,2),
7 City VARCHAR2(10BYTE),
8 Description
VARCHAR2
(15
BYTE) 10)

11 /

Table created.

SQL> CREATE OR REPLACE TRIGGER employee_ insert_


update BEFORE INSERT OR UPDATE ON employee FOR
EACH ROW 4DECLARE

5 dup_ flag INTEGER; 6BEGIN


--Force all employee names toupper case.

:NEW. first_ name :=UPPER(:NEW. first_name);

9END; 10 /

SQL> insert into Employee(ID, First_Name, Last_Name, Start_Date, End_Date, Salary, City,
Description)
2 values('01','Jason', 'Martin',
to_date('19960725','YYYYMMDD'),
to_date('20060725','YYYYMMDD'), 1234.56, 'Toronto',
'Programmer') 3 /

1 row created

SQL> insert into Employee(ID, First_Name, Last_Name, Start_Date, End_Date, Salary, City,
Description)
1 values('02','Alison', 'Mathews',
to_date('19760321','YYYYMMDD'),
to_date('19860221','YYYYMMDD'), 6661.78,
'Vancouver','Tester')
29 /
1row created.
SQL> insert into Employee(ID, First_Name, Last_Name, Start_Date,
End_Date, Salary, City, Description)
30 values('03','James', 'Smith',
to_date('19781212','YYYYMMDD'),
to_date('19900315','YYYYMMDD'), 6544.78,
'Vancouver','Tester') 3 /

1 row created.
SQL> insert into Employee(ID, First_Name, Last_Name, Start_Date,
End_Date, Salary, City, Description)
2 values('04','Celia', 'Rice',
to_date('19821024','YYYYMMDD'),
to_date('19990421','YYYYMMDD'),
2344.78,'Vancouver','Manager') 3 /
1 row created.

SQL> insert into Employee(ID, First_Name, Last_Name, Start_Date, End_Date,


Salary, City, Description)
2 values('05','Robert',
'Black',to_date('19840115','Y
YYYMMDD'),
to_date('19980808','YYYYMMDD'),
2334.78,'Vancouver','Tester')
3/
1 row created.

SQL> insert into Employee(ID, First_Name, Last_Name,


Start_Date, End_Date, Salary, City, Description)
2

values('06','Linda',
'Green',
to_date('19870730','YY
YYMMDD'),
to_date('19960104','YY
YYMMDD'),
4322.78,'NewYork','Tester')
3/
1 row created.
SQL> insert into Employee(ID, First_Name, Last_Name,
Start_Date, End_Date, Salary, City, Description)
2

values('07','David',
'Larry',
to_date('19901231','YY
YYMMDD'),
to_date('19980212','YY
YYMMDD'),
7897.78,'NewYork','Manager')3 /

1 row created.

SQL> insert into Employee(ID, First_Name, Last_Name,


Start_Date, End_Date, Salary, City, Description)
2 values('08','James',
'Cat',
to_date('19960917','
YYYYMMD D'),
to_date('20020415','YYYYMMDD'),
1232.78,'Vancou
ver','Tester') 3 /1
row created.

SQL> Select * from Employee 2


ID FIRST_NAME LAST_NAMESTART_DATEND_DATE
SALARYCITY
DESCRIPTION

01 JASON Martin 25-JUL-96 25-JUL-06 Toronto program


1234.56

02 ALISON Mathe 21-MAR-76 21-FEB-86 Vancouver Tester


ws 6661.78
03 JAMES Smith 12-DEC-78 15-MAR-90 Vancouver Tester
6544.78
04 CELIA Rice 24-OCT-82 21-APR-99 Vancouver Manager
2344.78
05 ROBER Black 15-JAN-84 08-AUG-98 Vancouver Tester
2334.78
T
06 LINDA Green 30-JUL-87 04-JAN-96 New YorkTester
4322.78
07 DAVID Larry 31-DEC-90 12-FEB-98 New York Manager
7897.78
08 JAMES Cat 17-SEP-96 15-APR-02 Vancouver Tester
1232.78

8 rows selected.

SQL> drop
table
Employee 2 /
Table
dropped.

SQL> CREATE OR REPLACE TRIGGERemployee_before_delete


2 BEFOREDELETE
3 ON employee
4 FOR EACHROW
5 DECLARE
6 v_usernamevarchar2(10);
7 BEGIN
8 -- Find username of person performing the DELETE on thetable
9 SELECT user INTOv_username
10 FROMdual;
11 -- Insert record into audit table
12 INSERT INTO employee_audit (id, salary, delete_date,deleted_by)
13 VALUES (:old.id,:old.salary, sysdate, v_username);
14 END;
15 /
Trigger created.

SQL> delete from


employee; 8 rows deleted.
SQL> select * from
employee_audit;

ID SALARY DELETE _DADELETED_BY

01 234.56 09-SEP-
06JAVA2S
02 6661.78 09-SEP-
06JAVA2S
03 6544.78 09-SEP-
06JAVA2S
04 2344.78 09-SEP-
06JAVA2S
05 2334.78 09-SEP-
06JAVA2S
06 4322.78 09-SEP-
06JAVA2S

07 7897.78 09-SEP-
06JAVA2S
08 1232.78 09-SEP-
06JAVA2S

8 rows selected.

SQL>drop table
employee_audit;T
able dropped
RESULT:
Thus The SQL Comment Was Successfully Executed.
EX.NO:8 Database design using EER-to-ODB mapping /
UML class diagrams

AIM:

To develop and execute a Database design using EER-to-ODB mapping / UML class
diagrams

PROCEDURE:

STEP 1: Start

STEP 2: Initialize the t with specific table id.

STEP 3:Specify the operations (update, delete, insert) for which to be executed.

STEP 4: Execute the procedure for both Before and After sequences

STEP 5: Carryout the operation on the table to check for execution.

STEP 6: Stop

Relationships between classes


UML is not just about pretty pictures. If used correctly, UML precisely conveys how
code should be implemented from diagrams. If precisely interpreted, the implemented code
will correctly reflect the intent of the designer.
Can you describe what each of the relationships mean relative to your target
programming language shown in the Figure below?
If you can't yet recognize them, no problem this section is meant to help you to
understand UML class relationships.
A class may be involved in one or more relationships with other classes. A relationship
can be one of the following types:
Inheritance (or Generalization):

The figure below shows an inheritance example with two styles. Although
the connectors are drawn differently, they are semantically equivalent.

Inheritance Example - Shapes


Association
Associations are relationships between classes in a UML Class Diagram. They are
represented by a solid line between classes. Associations are typically named using a
verb or verb phrase which reflects the real world problem domain.

Simple Association
 A structural link between two peer classes.
 There is an association between Class1 and Class2
The figure below shows an example of simple association. There is an association that
connects the <<control>> class Class1 and <<boundary>> class Class2. The relationship
is displayed as a solid line connecting the two classes.
Cardinality
Cardinality is expressed in terms of:
 one to one
 one to many
 many to many

Aggregation
A special type of association.
 It represents a "part of" relationship.
 Class2 is part of Class1.
 Many instances (denoted by the *) of Class2 can be associated with Class1.
 Objects of Class1 and Class2 have separate lifetimes.
The figure below shows an example of aggregation. The relationship is displayed as a
solid line with a unfilled diamond at the association end, which is connected to the
class that represents the aggregate.

Realization
1. Realization is a relationship between the blueprint class and the object containing
its respective implementation level details.
2. This object is said to realize the blueprint class. In other words, you can understand
this as the relationship between the interface and the implementing class.
Class Diagram Example: Order System

For example, the Owner interface might specify methods for acquiring
property and disposing of property.

Class
Diagram Example: GUI
A class diagram may also have notes attached to classes or relationships.

RESULT:
Thus The SQL Comment Was Successfully Executed.
EX:NO :9 Object features of SQL-UDTs and
sub-types,
Tables using UDTs, Inheritance, Method definition

AIM:
To design a Object features of SQL-UDTs and sub-types, Tables using UDTs,
Inheritance, Method definition

PROCEDURE:

STEP 1: Start

STEP 2: Create the form with essential controls and insert the menu using menu editor.

STEP 3: Write the code for doing the appropriate functions.

STEP 4: Save the forms and project.

STEP 5: Execute the form.

STEP 6: Stop

Supertypes and Subtypes


A subtype can be derived from a supertype either directly or indirectly through
intervening levels of other subtypes.
A supertype can have multiple sibling subtypes, but a subtype can have at most
one direct parent supertype (single inheritance).
Figure 2-1 Supertypes and Subtypes in Type Hierarchy
Creating a Parent or Subtype Object

Creating the Parent or Subtype person_typ Object

Copy
DROP TYPE person_typ FORCE;
-- if created
CREATE OR REPLACE TYPE person_typ AS OBJECT (
idno NUMBER,
name VARCHAR2(30),
phone VARCHAR2(20),
MAP MEMBER FUNCTION get_idno RETURN NUMBER,
MEMBER FUNCTION show RETURN VARCHAR2)
NOT FINAL;
/

CREATE OR REPLACE TYPE BODY person_typ AS


MAP MEMBER FUNCTION get_idno RETURN NUMBER IS
BEGIN
RETURN idno;
END;
-- function that can be overriden by subtypes
MEMBER FUNCTION show RETURN VARCHAR2 IS
BEGIN
RETURN 'Id: ' || TO_CHAR(idno) || ', Name: ' || name;
END;

END;
/
Creating A Student_Typ Subtype Using The UNDER Clause
Copy
-- requires Ex. 2-14
CREATE TYPE student_typ UNDER person_typ (
dept_id NUMBER,
major VARCHAR2(30),
OVERRIDING MEMBER FUNCTION show RETURN VARCHAR2)
NOT FINAL;
/

CREATE TYPE BODY student_typ AS


OVERRIDING MEMBER FUNCTION show RETURN VARCHAR2 IS
BEGIN
RETURN (self AS person_typ).show || ' -- Major: ' || major ;
END;

END;
/

Hierarchy of Types

Inserting Values into Substitutable Columns of a Table

Copy
DROP TYPE person_typ FORCE;
-- if previously created

DROP TYPE student_typ FORCE; -- if previously created

DROP TYPE part_time_student_typ FORCE; -- if previously created


DROP TABLE contacts; if previously created
CREATE OR REPLACE TYPE person_typ AS OBJECT (
idno NUMBER,
name VARCHAR2(30),
phone VARCHAR2(20))
NOT FINAL;/
CREATE TYPE student_typ UNDER person_typ (
dept_id NUMBER,
major VARCHAR2(30))
NOT FINAL;
/
CREATE TYPE part_time_student_typ UNDER student_typ (
number_hours NUMBER);
/
CREATE TABLE contacts (
contact person_typ,
contact_date DATE );

INSERT INTO contacts


VALUES (person_typ (12, 'Bob Jones', '650-555-0130'), '24 Jun
2003' );

INSERT INTO contacts


VALUES (student_typ(51, 'Joe Lane', '1-650-555-0178', 12,
'HISTORY'),
'24 Jun 2003' );

INSERT INTO contacts


VALUES (part_time_student_typ(52, 'Kim Patel', '1-650-555-0190',
14,
'PHYSICS', 20), '24 Jun 2003' );
RESULT:
Thus The SQL Comment Was Successfully Executed.
EX: NO: 10 Querying the Object-relational database using
Objet Query language

AIM:

To design a Querying the Object-relational database using Objet Query language

PROCEDURE:

STEP 1: Start

STEP 2: Create the form with essential controls and insert the menu using menu editor.

STEP 3: Write the code for doing the appropriate functions.

STEP 4: Save the forms and project.

STEP 5: Execute the form and generate report

STEP 6: Stop

Coding:
Private Sub ab_Click()
RichTextBox1.SelFontName = "Arial Black"
End Sub

Private Sub al_Click()

End Sub

Private Sub bold_Click()


RichTextBox1.SelBold = True
End Sub

Private Sub cb_Click()


RichTextBox1.SelColor = vbblue
End Sub

Private Sub cl_Click()


RichTextBox1.SelColor = vbred
End Sub

Private Sub copy_Click()


'Clipboard.SetText "richtextbox1.seltext", 1
'MsgBox Clipboard.GetText
Clipboard.SetText RichTextBox1.SelText, 1
RichTextBox1.SelText = Clipboard.GetText
MsgBox Clipboard.GetText
End Sub

Private Sub eighteen_Click()


RichTextBox1.SelFontSize = 18
End Sub

Private Sub exit_Click()


End
End Sub

Private Sub fcg_Click() RichTextBox1.SelColor

Private Sub fourteen_Click()


RichTextBox1.SelFontSize = 14
End Sub

Private Sub helpp_Click()


ans = MsgBox("visual basic sample notepad......!", vbYes + vbinforamtion, "Help")
If ans = vbYes Then
Unload Me
End If
End Sub

Private Sub italic_Click()


RichTextBox1.SelItalic = True
End Sub

Private Sub MC_Click()


RichTextBox1.SelFontName = "Monotype Corsiva"
End Sub

Private Sub new_Click()


RichTextBox1 = ""
End Sub

Private Sub open_Click()


RichTextBox1.LoadFile ("C:\Notepad\Document.rtf")
End Sub

Private Sub paste_Click()


RichTextBox1.SelText = Clipboard.GetText
End Sub

Private Sub save_Click()


RichTextBox1.SaveFile ("C:\Notepad\Document.rtf")
End Sub
Private Sub sixteen_Click()
RichTextBox1.SelFontSize = 16
End Sub

Private Sub Th_Click()


RichTextBox1.SelFontName = "Tahoma"
End Sub

Private Sub tn_Click()


RichTextBox1.SelFontName = "Times New Roman"
End Sub

Private Sub twele_Click()


RichTextBox1.SelFontSize = 12
End Sub

Private Sub underline_Click()


RichTextBox1.SelUnderline = True
End Sub

Private Sub vbblue_Click()


RichTextBox1.SelColor = vbblue
End Sub

Private Sub vbgreen_Click()


RichTextBox1.SelColor = vbgreen
End Sub

Private Sub vbred_Click()


RichTextBox1.SelColor = vbred
End Sub
Output: File Menu:

Fig.1. File Menu

Edit Menu

Fig.2. Edit Menu

Format Menu:
Fig.3. Format Menu

RESULT:
Thus The SQL Comment Was Successfully Executed.

You might also like