Changes between Initial Version and Version 1 of RelationalDesign


Ignore:
Timestamp:
08/20/26 18:47:36 (32 hours ago)
Author:
231035
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • RelationalDesign

    v1 v1  
     1= Relation Design
     2== Notation
     3* PK marked with [PK]
     4* FK marked with [FK→Table(column)]
     5* UQ = unique constraint
     6== Relation schema
     7{{{USERS + SUBTYPES}}}
     8* Users(user_id [PK], username [UQ], email [UQ], name, surname, created_at)
     9* Admin(user_id [PK, FK→Users(user_id)])
     10* Client(user_id [PK, FK→Users(user_id)])
     11* Owner(user_id [PK, FK→Client(user_id)]) (Owner is a subtype of Client, as in the diagram)
     12* Vet_clinic(user_id [PK, FK→vet_clinic(user_id)])
     13
     14{{{NOTIFICATIONS}}}
     15* Notification(notification_id [PK], user_id [FK→Users(user_id)], type, message, is_read, created_at)
     16
     17{{{VET CLINIC APPLICATIONS}}}
     18* vet_clinic_applications(application_id[PK],name,email,phone,city,address,submitted_at,status,reviewd_at,reviewd_by[FK→Admin(user_id)],denial_reason)
     19 
     20{{{VET CLINICS}}}
     21* !VetClinic(clinic_id [PK], name, email, phone, city, address, user_if(FK→vet_clinic(user_id)),application_id[FK→vet_clinic_applications(application_id)])
     22
     23{{{ANIMALS}}}
     24* Animal(animal_id [PK], owner_id [FK→Owner(user_id)], name, sex, date_of_birth, photo_url, type, species, breed, located_name)
     25
     26{{{LISTINGS}}}
     27* Listing(listing_id [PK], owner_id [FK→Owner(user_id)], animal_id [FK→Animal(animal_id)], status, price, description, created_at)
     28{{{FAVORITE LISTINGS}}}
     29* favorite_listings(client_id[FK→User(user_id)],listing_id[FK→Listing(listing_id)])→The whole thing is the PK
     30
     31{{{APPOINTMENTS}}}
     32* Appointment(appointment_id [PK], clinic_id [FK→!VetClinic(clinic_id)], animal_id [FK→Animal(animal_id)], responsible_owner_id [FK→Owner(user_id)], status, date_time, notes)
     33
     34{{{REVIEWS (SUPERTYPE + SUBTYPES)}}}
     35* Review(review_id [PK], reviewer_id [FK→Client(user_id)], rating, comment, created_at)
     36* !UserReview(review_id [PK, FK→Review(review_id)], target_user_id [FK→Users(user_id)])
     37* !ClinicReview(review_id [PK, FK→Review(review_id)], target_clinic_id [FK→!VetClinic(clinic_id)])
     38
     39{{{HEALTH RECORDS}}}
     40* !HealthRecord(healthrecord_id [PK], animal_id [FK→Animal(animal_id)], appointment_id [FK→Appointment(appointment_id)], type, description, date)
     41
     42{{{CLINIC UNAVAILABLE SLOTS}}}
     43* clinic_unavailable_slots(slot_id[PK],clinic_id[FK→vet_clinics(clinic_id)],date_time,reason,created_at)
     44----
     45Business rules enforced in DDL:
     46[[BR]]
     47Review rating range (1–5)
     48[[BR]]
     49Disjoint review specialization (a Review can be either !UserReview or !ClinicReview, not both) via trigger
     50[[BR]]
     51Clinic review constraint: reviewer must have at least one DONE appointment at that clinic (via trigger)
     52[[BR]]
     53!HealthRecord consistency: its animal_id must match appointment.animal_id (via trigger)
     54== DDL
     55 * [attachment:schema_creation.sql]
     56== DML
     57* [attachment:data_load.sql]
     58== Relational diagram
     59[[Image(relational_schema.jpg)]]