Changes between Version 1 and Version 2 of P2


Ignore:
Timestamp:
01/03/26 13:28:43 (2 weeks ago)
Author:
193284
Comment:

Added logical and physical database design including relational schema and SQL DDL

Legend:

Unmodified
Added
Removed
Modified
  • P2

    v1 v2  
    1 = Phase P2 – Relational Model
     1== Logical Database Design (Relational Schema)
    22
    3 This phase describes the relational schema derived from the ER model.
     3The logical database design is derived from the ER model and defines the relational schema
     4with primary and foreign keys.
     5
     6User(user_id PK, first_name, last_name, email, phone_number, gender, birthday)
     7
     8Wedding(wedding_id PK, date, budget, notes, user_id FK)
     9
     10Event(event_id PK, event_type, date, start_time, end_time, status, wedding_id FK)
     11
     12Guest(guest_id PK, first_name, last_name, email, wedding_id FK)
     13
     14Attendance(attendance_id PK, status, role, table_number, guest_id FK, event_id FK)
     15Note: table_number is optional because not all events require seating arrangements.
     16
     17Venue(venue_id PK, name, location, city, address, capacity, menu, phone_number, price_per_guest)
     18
     19Venue_Type(type_id PK, type_name)
     20
     21Venue_booking(booking_id PK, date, start_time, end_time, status, price, wedding_id FK, venue_id FK)
     22
     23
     24== Physical Database Design (SQL DDL)
     25
     26The following SQL DDL statements illustrate the creation of the core database tables.
     27Only representative tables are shown; the remaining tables follow the same design principles.
     28
     29{{{
     30CREATE TABLE User (
     31    user_id INT PRIMARY KEY,
     32    first_name VARCHAR(50) NOT NULL,
     33    last_name VARCHAR(50) NOT NULL,
     34    email VARCHAR(100) UNIQUE NOT NULL,
     35    phone_number VARCHAR(20),
     36    gender VARCHAR(10),
     37    birthday DATE
     38);
     39
     40CREATE TABLE Wedding (
     41    wedding_id INT PRIMARY KEY,
     42    date DATE NOT NULL,
     43    budget DECIMAL(10,2),
     44    notes TEXT,
     45    user_id INT NOT NULL,
     46    FOREIGN KEY (user_id) REFERENCES User(user_id)
     47);
     48
     49CREATE TABLE Event (
     50    event_id INT PRIMARY KEY,
     51    event_type VARCHAR(50) NOT NULL,
     52    date DATE NOT NULL,
     53    start_time TIME NOT NULL,
     54    end_time TIME NOT NULL,
     55    status VARCHAR(20) NOT NULL,
     56    wedding_id INT NOT NULL,
     57    FOREIGN KEY (wedding_id) REFERENCES Wedding(wedding_id)
     58);
     59}}}
     60
     61
     62== Constraints and Assumptions
     63
     64* Primary keys uniquely identify each entity.
     65* Foreign keys enforce referential integrity.
     66* Each wedding is managed by exactly one user.
     67* Bookings cannot overlap for the same resource.