| 3 | | This phase describes the relational schema derived from the ER model. |
| | 3 | The logical database design is derived from the ER model and defines the relational schema |
| | 4 | with primary and foreign keys. |
| | 5 | |
| | 6 | User(user_id PK, first_name, last_name, email, phone_number, gender, birthday) |
| | 7 | |
| | 8 | Wedding(wedding_id PK, date, budget, notes, user_id FK) |
| | 9 | |
| | 10 | Event(event_id PK, event_type, date, start_time, end_time, status, wedding_id FK) |
| | 11 | |
| | 12 | Guest(guest_id PK, first_name, last_name, email, wedding_id FK) |
| | 13 | |
| | 14 | Attendance(attendance_id PK, status, role, table_number, guest_id FK, event_id FK) |
| | 15 | Note: table_number is optional because not all events require seating arrangements. |
| | 16 | |
| | 17 | Venue(venue_id PK, name, location, city, address, capacity, menu, phone_number, price_per_guest) |
| | 18 | |
| | 19 | Venue_Type(type_id PK, type_name) |
| | 20 | |
| | 21 | Venue_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 | |
| | 26 | The following SQL DDL statements illustrate the creation of the core database tables. |
| | 27 | Only representative tables are shown; the remaining tables follow the same design principles. |
| | 28 | |
| | 29 | {{{ |
| | 30 | CREATE 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 | |
| | 40 | CREATE 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 | |
| | 49 | CREATE 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. |