Semester: 3 Semester | Department: Computer Science Engineering
Mentor: Guruprasad Konnurmath | Course Code: 15ECSC208
Welcome to my DBMS portfolio. Here, I showcase my journey and accomplishments in learning database management systems.
I am an aspiring database professional passionate about designing efficient, secure, and reliable database systems.
Task: Design and manage a pharmaceutical database as per the given specifications.
Solution:
The ER diagram includes the following entities and relationships:
- Entities:
- Pharmaceutical_Company: Company_Name (PK), Phone_No
- Drug: Trade_Name (PK), Drug_Name, Formula, Company_Name (FK)
- Pharmacy: Pharmacy_ID (PK), Name, Address, Phone_No
- Patient: Patient_ID (PK), Name, Age, Address
- Doctor: Doctor_ID (PK), Name, Specialty, Years_Experience
- Prescription: Prescription_ID (PK), Doctor_ID (FK), Patient_ID (FK), Date, Quantity
- Contract: Contract_ID (PK), Pharmacy_ID (FK), Company_Name (FK), Start_Date, End_Date, Terms, Supervisor
- Relationships:
- Sells: Between Pharmacy and Drug, with Price as an attribute.
- Prescribes: Between Doctor and Patient, linked via Prescription.
- Has_Contract: Between Pharmacy and Pharmaceutical_Company, linked via Contract.
The schema derived from the ER diagram includes:
- Pharmaceutical_Company: Company_Name (PK), Phone_No
- Drug: Trade_Name (PK), Drug_Name, Formula, Company_Name (FK)
- Pharmacy: Pharmacy_ID (PK), Name, Address, Phone_No
- Patient: Patient_ID (PK), Name, Age, Address
- Doctor: Doctor_ID (PK), Name, Specialty, Years_Experience
- Sells: Pharmacy_ID (PK, FK), Trade_Name (PK, FK), Price
- Prescribes: Prescription_ID (PK), Doctor_ID (FK), Patient_ID (FK), Date, Quantity
- Contract: Contract_ID (PK), Pharmacy_ID (FK), Company_Name (FK), Start_Date, End_Date, Terms, Supervisor
Populated tables with sample records:
Pharmaceutical_Company
| Company_Name | Phone_No |
|-------------------|-------------|
| MedCorp | 1234567890 |
| HealthCare Ltd. | 9876543210 |
Drug
| Trade_Name | Drug_Name | Formula | Company_Name |
|------------|-------------|----------|----------------|
| Panadol | Paracetamol | C8H9NO2 | MedCorp |
Demonstrating concepts:
- Multiple table join operations:
SELECT Doctor.Name, Patient.Name, Drug.Trade_Name, Prescription.Quantity FROM Prescription JOIN Doctor ON Prescription.Doctor_ID = Doctor.Doctor_ID JOIN Patient ON Prescription.Patient_ID = Patient.Patient_ID JOIN Drug ON Prescription.Drug_ID = Drug.Trade_Name WHERE Prescription.Quantity > 2; - Clauses & Functions:
SELECT Pharmacy.Name, COUNT(Sells.Trade_Name) AS Drug_Count FROM Pharmacy JOIN Sells ON Pharmacy.Pharmacy_ID = Sells.Pharmacy_ID GROUP BY Pharmacy.Name HAVING COUNT(Sells.Trade_Name) > 3; - Subqueries:
SELECT Name FROM Pharmacy WHERE Pharmacy_ID = (SELECT Pharmacy_ID FROM Sells WHERE Trade_Name = 'Panadol'); - Views:
CREATE VIEW DrugPrices AS SELECT Trade_Name, Pharmacy.Name, Price FROM Sells JOIN Pharmacy ON Sells.Pharmacy_ID = Pharmacy.Pharmacy_ID;
Email: 01fe23bcs228@kletech.ac.in
LinkedIn: linkedin.com/in/yourprofile
GitHub: github.com/yourprofile