0% found this document useful (0 votes)
223 views

Medical Agency Project

This database project models the operations of a medical agency. It includes tables for the company, medicines produced, employees, distributors, medical stores, salesmen and their orders. The document includes sample data and SQL queries to retrieve information from the tables such as medicine names, production details, sales figures and employee details. It demonstrates how the medical agency works from production to distribution and sales.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
223 views

Medical Agency Project

This database project models the operations of a medical agency. It includes tables for the company, medicines produced, employees, distributors, medical stores, salesmen and their orders. The document includes sample data and SQL queries to retrieve information from the tables such as medicine names, production details, sales figures and employee details. It demonstrates how the medical agency works from production to distribution and sales.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9

Medical

Agency
Database
Project
Made by :

Milind Nehete - B02


Salil Sawant – B28
Preface :
In Medical Agency Database Project, we have
shown how a medical agency produces and sells its
products to various distributors which eventually
reach the end customer.
This database can be used to get the
information about the company, the medicine it
produces, the distributor which sells that medicine
as well as details about various employees working
for all establishments.
In short, we have shown how a medical
agency actually works.
SQL> desc company
Name Null? Type
----------------------------------------- --------------- ----------------------------
EMP_NO NOT NULL NUMBER
EMP_NAME VARCHAR2(20)

SQL> desc medicine


Name Null? Type
----------------------------------------- --------------- ----------------------------
MED_NO NOT NULL NUMBER
MED_NAME VARCHAR2(20)
MFG_DATE NUMBER
EXP_DATE NUMBER

SQL> desc makes


Name Null? Type
----------------------------------------- -------- ----------------------------
M_EMP_NO NUMBER
M_MED_NO NUMBER

SQL> desc med_distributor


Name Null? Type
----------------------------------------- --------------- ----------------------------
D_NO NOT NULL NUMBER
D_NAME VARCHAR2(20)
AREA_CODE NUMBER

SQL> desc gives_to


Name Null? Type
----------------------------------------- -------- ----------------------------
GIV_D_NO NUMBER
GIV_MED_NO NUMBER

SQL> desc med_store


Name Null? Type
----------------------------------------- ------------- ----------------------------
STORE_ID NOT NULL NUMBER
STORE_NAME VARCHAR2(20)
STORE_LOC VARCHAR2(20)

SQL> desc supplies_to


Name Null? Type
----------------------------------------- -------- ----------------------------
SUP_D_NO NUMBER
SUP_STORE_ID NUMBER
SUPPLY_DATE DATE

SQL> desc salesman


Name Null? Type
----------------------------------------- --------------- ----------------------------
S_ID NOT NULL NUMBER
S_NAME VARCHAR2(20)

SQL> desc orders


Name Null? Type
----------------------------------------- -------- ----------------------------
ORD_S_ID NUMBER
ORD_STORE_ID NUMBER
ORDER_DATE DATE
ORD_QTY NUMBER

SQL> desc works_for


Name Null? Type
----------------------------------------- -------- ----------------------------
W_S_ID NUMBER
W_D_NO NUMBER

SQL> desc order_checking


Name Null? Type
----------------------------------------- --------------- ----------------------------
S_ID NOT NULL NUMBER
ORDER_NO NUMBER

SQL> desc payment_checking


Name Null? Type
----------------------------------------- --------------- ----------------------------
S_ID NOT NULL NUMBER
PAY_DATE DATE
PAY_AMT NUMBER

SQL> select * from company;

EMP_NO EMP_NAME
------------ --------------------
101 rakesh
102 jitesh
103 ravi
104 salil
105 milind

SQL> select * from medicine;


MED_NO MED_NAME MFG_DATE EXP_DATE
---------- ----------------------- ---------------- ----------------
1 brufen 12-APR-06 12-MAY-06
2 crosin 04-MAR-06 04-JUL-06
3 mox 15-MAY-06 30-AUG-06
4 ciplox 25-SEP-06 25-NOV-06
5 disprin 10-JUN-06 10-OCT-06

SQL> select * from makes;

M_EMP_NO M_MED_NO
---------------- ----------
101 4
102 1
103 3
104 2
105 5

SQL> select * from med_distributor;

D_NO D_NAME AREA_CODE


---------- ------------------ -------------------
1000 ranbaxy 01
2000 glaxo 02
3000 thyrocare 03

SQL> select * from gives_to;

GIV_MED_NO GIV_D_NO
---------- ----------
3 1000
1 2000
5 3000
4 1000
2 2000

SQL> select * from med_store;

STORE_ID STORE_NAME STORE_LOC


---------- -------------------- --------------------
111 krishna thane
222 vishnu mulund
333 bramha bhandup
444 laxmi vikhroli
SQL> select * from supplies_to;

SUP_D_NO SUP_STORE_ID SUPPLY_DA


---------- ------------ ---------
1000 222 12-JUN-06
2000 333 26-JUL-06
3000 111 22-MAR-06

SQL> select * from salesman;

S_ID S_NAME
---------- --------------------
1 yogesh
2 samir
3 firoz
4 gaurav
5 viral

SQL> select * from orders;

ORD_S_ID ORD_STORE_ID ORDER_DAT ORD_QTY


---------- ------------ --------- ----------
1 111 15-JUN-06 200
2 333 20-AUG-06 250
5 444 25-DEC-06 100

SQL> select * from works_for;

W_S_ID W_D_NO
---------- ----------
1 1000
2 2000
3 1000
4 3000
5 2000

SQL> select * from order_checking;

S_ID ORDER_NO
---------- ----------
1 10
2 20

SQL> select * from payment_checking;

S_ID PAY_DATE PAY_AMT


---------- --------- ----------
3 10-MAY-06 3000
4 15-JUL-06 4500
5 30-SEP-06 4000

SQL QUERIES :
1. Give the name of a medicine which is sold to distributor ranbaxy.

SQL> select med_name from medicine where med_no = (select giv_med_no from
gives_to where giv_d_no=(select d_no from med_distributor where
d_name='thyrocare'))

MED_NAME
--------------------
disprin

2. Give name of medicine which was produced on 12 April, 2006.

SQL> select med_name from medicine where med_no=(select m_med_no from


makes where mfg_date='12 april 2006');

MED_NAME
--------------------
ciplox

3. Increase the number of units ordered by medical store Laxmi to 600.

SQL> select * from orders;

ORD_S_ID ORD_STORE_ID ORDER_DAT ORD_QTY


--------------- ---------------------- ------------------- ---------------
1 111 15-JUN-06 200
2 333 20-AUG-06 250
5 444 25-DEC-06 100

SQL> update orders set ord_qty = 600 where ord_store_id = (select store_id from
med_store where store_name='laxmi');

1 row updated.

SQL> select * from orders;

ORD_S_ID ORD_STORE_ID ORDER_DAT ORD_QTY


---------- ------------ --------- ----------
1 111 15-JUN-06 200
2 333 20-AUG-06 250
5 444 25-DEC-06 600

4. Find number of units of a medicine catered by salesman Yogesh.

SQL> select ord_qty from orders where ord_s_id=(select s_id from salesman where
s_name= 'yogesh');

ORD_QTY
---------------
200

5. Give the name of a medicine which will expire on 10 October, 2006.

SQL> select med_name from medicine where med_no=(select m_med_no from


makes where exp_date='10 october 2006');

MED_NAME
--------------------
disprin

6. Give names of all medicines which were manufactured on the month of


April.

SQL> select med_name from medicine where med_no=(select m_med_no from


makes where mfg_date between '1 april 2006' and '30 april 2006')

MED_NAME
--------------------
ciplox

7. Give the name and location of the medical store which has ordered the most
amount of any medicine from the distributor.

SQL> select store_name,store_loc from med_store where store_id=(select


ord_store_id from orders where ord_qty=(select max(ord_qty) from orders))

STORE_NAME STORE_LOC
-------------------- ---------------------
laxmi vikhroli

8. The medicine name “crosin” has been scrapped and a new name has been
assigned to it, “aspirin”. Make the changes accourdingly.
SQL> update medicine
2 set med_name='aspirin' where med_name='crosin';

1 row updated.

SQL> select * from medicine;

MED_NO MED_NAME
---------- --------------------
1 brufen
2 aspirin
3 mox
4 ciplox
5 disprin

9. Give name and ID of salesmen working for glaxo.

SQL> select s_name Name,w_s_id ID from salesman,works_for where


w_d_no=(select d_no from med_distributor where d_name='glaxo') and
works_for.w_s_id=salesman.s_id

NAME ID
-------------------- ----------
samir 2
viral 5

10. Give the payable amount along with receipt number of the recent order
made by Vishnu medical store.

SQL> select pay_amt,reciept_no from payment_checking,salesman where


salesman.s_id=(select ord_s_id from orders where ord_store_id=(select store_id from
med_store where store_name='krish

PAY_AMT RECIEPT_NO
---------------- ------------------
3000 ar001

You might also like