I'll provide the DBML code based on the comprehensive BCNF normalization we just completed. This DBML schema incorporates all the insights from our normalization process.
// Veterinary Clinic Database Schema
// Fully Normalized to BCNF (Boyce-Codd Normal Form)
// 1. Owner Entity
Table Owner {
Owner_ID int [pk, increment, note: 'Unique identifier for pet owner']
Owner_Name varchar(100) [not null, note: 'Full name of the owner']
Phone varchar(20) [note: 'Contact phone number']
Email varchar(100) [note: 'Contact email address']
Address varchar(200) [note: 'Full residential address']
}
// 2. Pet Entity
Table Pet {
Pet_ID int [pk, increment, note: 'Unique identifier for pet']
Name varchar(100) [not null, note: 'Pet\'s name']
Species varchar(50) [note: 'Type of animal']
Breed varchar(50) [note: 'Specific breed of the pet']
DOB date [not null, note: 'Date of birth']
Gender varchar(10) [note: 'Pet\'s gender']
Registration_Date date [not null, note: 'Date pet was registered in the clinic']
Owner_ID int [not null, ref: > Owner.Owner_ID, note: 'Reference to pet owner']
}
// 3. Veterinarian Entity
Table Veterinarian {
Vet_ID int [pk, increment, note: 'Unique identifier for veterinarian']
Name varchar(100) [not null, note: 'Full name of veterinarian']
Phone varchar(20) [note: 'Contact phone number']
Email varchar(100) [note: 'Contact email address']
Specialisation varchar(100) [note: 'Area of veterinary expertise']
Experience_Yrs int [note: 'Years of professional experience']
Salary decimal(12,2) [note: 'Monthly or annual salary']
}
// 4. Other Staff Entity
Table Other_Staff {
Staff_ID int [pk, increment, note: 'Unique identifier for staff member']
Name varchar(100) [not null, note: 'Full name of staff member']
Role varchar(50) [note: 'Job role or position']
Salary decimal(12,2) [note: 'Monthly or annual salary']
Email varchar(100) [note: 'Contact email address']
Contact_Number varchar(20) [note: 'Contact phone number']
}
// 5. Appointment Entity
Table Appointment {
Appointment_ID int [pk, increment, note: 'Unique identifier for appointment']
Date date [not null, note: 'Date of appointment']
Time time [not null, note: 'Time of appointment']
Reason varchar(200) [note: 'Purpose of the appointment']
Status varchar(20) [note: 'Current status of appointment']
Pet_ID int [not null, ref: > Pet.Pet_ID, note: 'Pet involved in appointment']
Vet_ID int [not null, ref: > Veterinarian.Vet_ID, note: 'Veterinarian conducting appointment']
Manager_Staff_ID int [not null, ref: > Other_Staff.Staff_ID, note: 'Staff member managing appointment']
}
// 6. Billing Entity
Table Billing {
Bill_ID int [pk, increment, note: 'Unique identifier for bill']
Date date [not null, note: 'Date of billing']
Status varchar(20) [note: 'Payment status']
Payment_Method varchar(30) [note: 'Method of payment']
Amount decimal(12,2) [not null, note: 'Total bill amount']
Appointment_ID int [not null, unique, ref: > Appointment.Appointment_ID, note: 'Associated appointment']
}
// 7. Medical Record Entity (BCNF Fix: Pet_ID as PK)
Table Medical_Record {
Pet_ID int [pk, ref: > Pet.Pet_ID, note: 'Pet\'s unique medical record']
Diagnosis varchar(200) [note: 'Medical diagnosis']
Treatments varchar(500) [note: 'Treatments prescribed']
Notes text [note: 'Additional medical notes']
Visit_Date date [not null, note: 'Date of medical visit']
Diagnosing_Vet_ID int [not null, ref: > Veterinarian.Vet_ID, note: 'Veterinarian who diagnosed']
}
// 8. Prescription Entity
Table Prescription {
Prescription_ID int [pk, increment, note: 'Unique identifier for prescription']
Issue_Date date [not null, note: 'Date prescription was issued']
Duration_Days int [not null, note: 'Duration of prescription']
Instructions varchar(500) [note: 'Prescription usage instructions']
Vet_ID int [not null, ref: > Veterinarian.Vet_ID, note: 'Veterinarian who issued prescription']
Pet_ID int [not null, ref: > Medical_Record.Pet_ID, note: 'Pet associated with prescription']
}
// 9. Medication Entity
Table Medication {
Medication_ID int [pk, increment, note: 'Unique identifier for medication']
Name varchar(100) [not null, note: 'Name of medication']
Dosage_Form varchar(50) [not null, note: 'Form of medication (tablet, liquid, etc.)']
Dosage varchar(50) [not null, note: 'Specific dosage instructions']
Storage_Temp varchar(30) [note: 'Required storage temperature']
Manufacturer varchar(100) [not null, note: 'Medication manufacturer']
Side_Effects varchar(200) [note: 'Potential side effects']
}
// 10. Prescription-Medication Junction Table
Table Prescription_Medication {
Prescription_ID int [pk, ref: > Prescription.Prescription_ID, note: 'Prescription identifier']
Medication_ID int [pk, ref: > Medication.Medication_ID, note: 'Medication identifier']
Quantity int [not null, note: 'Quantity of medication prescribed']
}
// 11. Vaccine Type Entity
Table Vaccine_Type {
Vaccine_Type_ID int [pk, increment, note: 'Unique identifier for vaccine type']
Vaccine_Name varchar(100) [not null, unique, note: 'Name of vaccine']
Dose varchar(50) [not null, note: 'Standard dosage']
Interval_Days int [not null, note: 'Recommended interval between doses']
Manufacturer varchar(100) [note: 'Vaccine manufacturer']
Notes text [note: 'Additional vaccine information']
}
// 12. Vaccination Entity
Table Vaccination {
Vaccination_ID int [pk, increment, note: 'Unique identifier for vaccination event']
Administration_Date date [not null, note: 'Date of vaccination']
Admin_Staff_ID int [not null, ref: > Other_Staff.Staff_ID, note: 'Staff who administered vaccination']
Vet_ID int [not null, ref: > Veterinarian.Vet_ID, note: 'Supervising veterinarian']
Vaccine_Type_ID int [not null, ref: > Vaccine_Type.Vaccine_Type_ID, note: 'Type of vaccine administered']
}
// 13. Pet-Vaccination Junction Table
Table Pet_Vaccination {
Pet_ID int [pk, ref: > Pet.Pet_ID, note: 'Pet receiving vaccination']
Vaccination_ID int [pk, ref: > Vaccination.Vaccination_ID, note: 'Specific vaccination event']
}
// 14. Staff Medical Record Update Tracking
Table Staff_Record_Update {
Staff_ID int [pk, ref: > Other_Staff.Staff_ID, note: 'Staff member who updated record']
Record_ID int [pk, ref: > Medical_Record.Pet_ID, note: 'Medical record updated']
Updated_At datetime [not null, default: `now()`, note: 'Timestamp of update']
Comment varchar(300) [note: 'Update comments or notes']
}
// Relationship Definitions for Clarity
Ref: Owner.Owner_ID < Pet.Owner_ID
Ref: Pet.Pet_ID < Appointment.Pet_ID
Ref: Veterinarian.Vet_ID < Appointment.Vet_ID
Ref: Other_Staff.Staff_ID < Appointment.Manager_Staff_ID
Ref: Appointment.Appointment_ID < Billing.Appointment_ID
Ref: Pet.Pet_ID < Medical_Record.Pet_ID
Ref: Veterinarian.Vet_ID < Medical_Record.Diagnosing_Vet_ID
Ref: Veterinarian.Vet_ID < Prescription.Vet_ID
Ref: Medical_Record.Pet_ID < Prescription.Pet_ID
Ref: Prescription.Prescription_ID < Prescription_Medication.Prescription_ID
Ref: Medication.Medication_ID < Prescription_Medication.Medication_ID
Ref: Vaccine_Type.Vaccine_Type_ID < Vaccination.Vaccine_Type_ID
Ref: Other_Staff.Staff_ID < Vaccination.Admin_Staff_ID
Ref: Veterinarian.Vet_ID < Vaccination.Vet_ID
Ref: Pet.Pet_ID < Pet_Vaccination.Pet_ID
Ref: Vaccination.Vaccination_ID < Pet_Vaccination.Vaccination_ID
Ref: Other_Staff.Staff_ID < Staff_Record_Update.Staff_ID
Ref: Medical_Record.Pet_ID < Staff_Record_Update.Record_ID
Key Improvements in this DBML Schema:
-
Full BCNF Normalization
- Eliminated redundant attributes
- Removed derived/computed columns
- Ensured all functional dependencies involve superkeys
-
Enhanced Readability
- Added
note attributes to explain each column's purpose
- Maintained clear, consistent naming conventions
- Included comprehensive relationship references
-
Flexible Design
- Supports complex veterinary clinic workflows
- Tracks detailed medical history
- Allows multiple relationships between entities
-
Integrity Constraints
- Unique constraints where appropriate
- Foreign key relationships
- Not-null constraints for critical fields
Recommended Next Steps:
- Generate SQL DDL from this DBML
- Create indexes for performance
- Implement application-level validation
- Design views for common queries
Would you like me to elaborate on any specific aspect of the schema or proceed with SQL DDL generation?