Q.01) Design The Database For Simple Trading Organization As Described Follow and Develop The PL/SQL Programs
Q.01) Design The Database For Simple Trading Organization As Described Follow and Develop The PL/SQL Programs
01) Design the database for Simple Trading Organization as described follow and develop the
PL/SQL Programs :
J(J#,JName,JCity)
SPJ(S#,P#,J#,QTY)
a) Find the project-wise total number of parts received from different supplies from a city taken as
input.
b) Find the total weight of parts particular colour part received from a supplier for a project taken as
input from user.
c) Create a logbook to store number records modified in supplier table during a day
SQL>
"S_NAME" VARCHAR2(4000),
"S_CITY" VARCHAR2(4000),
"STATUS" VARCHAR2(4000),
SQL>
"P_NAME" VARCHAR2(4000),
"WEIGHT" VARCHAR2(4000),
"COLOR" VARCHAR2(4000),
"P_CITY" VARCHAR2(4000),
);
Creating table JOB:
SQL>
"J_NAME" VARCHAR2(4000),
"J_CITY" VARCHAR2(4000),
);
SQL>
S_ID VARCHAR2(400),
P_ID VARCHAR2(400),
J_ID VARCHAR2(400),
QTY NUMBER(10,2),
);
Table SUPPLIER:
SQL>
Table JOB:
Table SPJ:
SQL QUERY:
a) Find the project-wise total number of parts received from different supplies from a city taken as
input.
SQL>
FROM SPJ,JOB
WHERE SPJ.J_ID=JOB.J_ID
AND JOB.J_CITY='LONDON'
ORDER BY J_NAME;
RESULT:
P_ID J_NAME
P_05 COLLATOR
P_04 COLLATOR
P_03 TAPE
b) Find the total weight of parts particular colour part received from a supplier for a project taken as
input from user
SQL>
FROM PARTS,SPJ,JOB
PARTS.P_ID=SPJ.P_ID AND
JOB.J_ID='J_03' AND
JOB.J_ID=SPJ.J_ID;
RESULT:
TOTAL WEIGHT
1800
c) Create a logbook to store number records modified in supplier table during a day
SQL>
Declare
int_count integer;
Begin
If UPDATING then
Select count(*) into int_count from LOGBOOK where date_modified like sysdate and
operations='Update';
If int_count>0 then
update LOGBOOK set records=records+1 where date_modified like sysdate and
operations='Update';
Else
End If;
End If;
If INSERTING then
Select count(*) into int_count from LOGBOOK where date_modified like sysdate and
operations='Insert';
If int_count>0 then
update LOGBOOK set records=records+1 where date_modified like sysdate and operations='Insert';
Else
End If;
End If;
If DELETING then
Select count(*) into int_count from LOGBOOK where date_modified like sysdate and
operations='Delete';
If int_count>0 then
update LOGBOOK set records=records+1 where date_modified like sysdate and operations='Delete';
Else
End If;
End If;
End;
RESULT:
1 row(s) deleted.
1 row(s) updated.
Q.02)Design the database for Manufacturing System as described follow and develop the PL/SQL
Programs
Product(P#,R#,QTY)
Sales(P#,QTY,City, DiscountRate)
"RM_NAME" VARCHAR2(4000),
"WEIGHT" NUMBER(5,2),
"VOLUME" NUMBER(10),
"CITY" VARCHAR2(4000),
"RATE" NUMBER(2),
);
P_ID VARCHAR2(400),
R_ID VARCHAR2(400),
QTY NUMBER(10,2),
P_ID VARCHAR2(400),
QTY NUMBER(10,2),
CITY VARCHAR2(400),
DISCOUNTRATE NUMBER(10,2),
Table RAWMATERIAL:
SQL>
Table PRODUCT:
SQL>
Table SALES:
SQL>
SQL>
RESULT:
RAWMATERIAL QTY R_ID
3291905 R_01
671700 R_04
SELECT SUM(SALES.QTY),RAWMATERIAL.R_ID FROM PRODUCT,RAWMATERIAL,SALES WHERE
SALES.CITY='KOLKATA'
SQL>
RESULT:
CITY MONEY EARN DISCOUNT
DELHI 631890870 93.6
KOLKATA 6399920350 1056
MUMBAI 631890870 280.8
JAMSEDPUR 7258643840 3225.6
CHENNAI 607587375 180
c) Create a logbook to store number records delete and updated in product table.
SQL>
Declare
int_count integer;
Begin
If UPDATING then
Select count(*) into int_count from LOGBOOK where date_modified like sysdate and
operations='Update';
If int_count>0 then
End If;
End If;
If DELETING then
Select count(*) into int_count from LOGBOOK where date_modified like sysdate and
operations='Delete';
If int_count>0 then
update LOGBOOK set records=records+1 where date_modified like sysdate and operations='Delete';
Else
End If;
End If;
End;
/
Trigger created.
RESULT:
Q.3)Design the database for Employee System as described follow and develop the PL/SQL
Programs
Employee (E#,D#,JobDuration)
TaxRate(YearlyEarning, TaxRate)
D_ID VARCHAR2(400),
D_NAME VARCHAR2(400),
BASICPAY NUMBER(10,2),
GRADEPAY NUMBER(10,2),
INCREMENT_RATE NUMBER(10,2),
E_ID VARCHAR2(400),
D_ID VARCHAR2(400),
JOB_DURATION VARCHAR2(400),
YEARLY_EARNING NUMBER(10,2),
INTEREST_RATE NUMBER(10,2));
Table DESIGNATION:
SQL>
Table DESIGNATION:
SQL>
Table DESIGNATION:
SQL>
SQL>
GROUP BY D_NAME;
RESULT:
D_NAME GROSS SALARY
S.D.O 134000
CLERK 11500
IAS 112000
B.D.O 66000
GROUP_D 6800
P2_OFFICER 47500
MANAGER 163000
P1_OFFICER 38500
SQL>
RESULT:
SQL>
Declare
int_count integer;
Begin
If UPDATING then
Select count(*) into int_count from LOGBOOK where date_modified like sysdate and
operations='Update';
If int_count>0 then
End If;
End If;
End;
/
Trigger created.
RESULT: