| | 1 | == Candidate Key Determination == |
| | 2 | |
| | 3 | As mentioned before, based on business rules of the Wedding Planner system, the following functional dependencies hold: |
| | 4 | |
| | 5 | || ID || Functional Dependency || Justification || |
| | 6 | || FD1 || user_id → user_first_name, user_last_name, user_email || User attributes depend only on user_id |
| | 7 | || FD2 || wedding_id → wedding_date, wedding_budget, user_id || A wedding uniquely defines its properties |
| | 8 | || FD3 || venue_id → venue_name, venue_type, venue_capacity || Venue attributes depend only on venue_id |
| | 9 | || FD4 || booking_id → venue_id, wedding_id, booking_date, start_time, end_time || A booking uniquely defines a venue reservation || |
| | 10 | === FD1: user_id → user_first_name, user_last_name, user_email === |
| | 11 | |
| | 12 | Proof: |
| | 13 | |
| | 14 | || Condition || Reason || |
| | 15 | || user_id is unique || Each user has exactly one system account |
| | 16 | || Name and email belong to the user || They do not depend on weddings or venues |
| | 17 | || Same user_id always gives same values || No variation allowed by system rules |
| | 18 | |
| | 19 | Conclusion: |
| | 20 | |
| | 21 | || Functional Dependency || |
| | 22 | || user_id → user_first_name, user_last_name, user_email || |
| | 23 | |
| | 24 | This dependency is non-transitive and deterministic. |
| | 25 | |
| | 26 | === FD2: wedding_id → wedding_date, wedding_budget, user_id === |
| | 27 | |
| | 28 | Proof: |
| | 29 | |
| | 30 | || Condition || Reason || |
| | 31 | || wedding_id is unique || Each wedding is registered once |
| | 32 | || Wedding date is fixed || A wedding cannot have multiple dates |
| | 33 | || Budget belongs to the wedding || Independent of venue choice |
| | 34 | || Each wedding has one owner || user_id identifies the organizer |
| | 35 | |
| | 36 | Conclusion: |
| | 37 | |
| | 38 | || Functional Dependency || |
| | 39 | || wedding_id → wedding_date, wedding_budget, user_id || |
| | 40 | |
| | 41 | This shows entity integrity for weddings. |
| | 42 | |
| | 43 | === FD3: venue_id → venue_name, venue_type, venue_capacity === |
| | 44 | |
| | 45 | Proof: |
| | 46 | |
| | 47 | || Condition || Reason || |
| | 48 | || venue_id is unique || One ID per physical venue |
| | 49 | || Name and type are static || Do not change per booking |
| | 50 | || Capacity is venue-specific || Independent of weddings |
| | 51 | |
| | 52 | Conclusion: |
| | 53 | |
| | 54 | || Functional Dependency || |
| | 55 | || venue_id → venue_name, venue_type, venue_capacity || |
| | 56 | |
| | 57 | Venue attributes are fully functionally dependent on venue_id. |
| | 58 | |
| | 59 | === FD4: booking_id → venue_id, wedding_id, booking_date, start_time, end_time === |
| | 60 | |
| | 61 | Proof: |
| | 62 | |
| | 63 | || Condition || Reason || |
| | 64 | || booking_id is unique || One booking per reservation |
| | 65 | || Booking ties venue and wedding || Both are required |
| | 66 | || Date and time define reservation || Cannot vary per booking || |
| | 67 | |
| | 68 | Conclusion: |
| | 69 | |
| | 70 | || Functional Dependency || |
| | 71 | || booking_id → venue_id, wedding_id, booking_date, start_time, end_time || |
| | 72 | |
| | 73 | This models a relationship entity (association table). |
| | 74 | |
| | 75 | == Step 3: Attribute Closure Calculation == |
| | 76 | |
| | 77 | To find a candidate key, we compute attribute closures. |
| | 78 | |
| | 79 | === Attempt 1: user_id⁺ === |
| | 80 | |
| | 81 | || Derived Attributes || |
| | 82 | || user_first_name, user_last_name, user_email || |
| | 83 | |
| | 84 | ❌ Does NOT determine wedding, venue, or booking data |
| | 85 | → Not a key |
| | 86 | |
| | 87 | === Attempt 2: wedding_id⁺ === |
| | 88 | |
| | 89 | || Derived Attributes || |
| | 90 | || wedding_date, wedding_budget, user_id, user_first_name, user_last_name, user_email || |
| | 91 | |
| | 92 | ❌ Missing venue and booking data |
| | 93 | → Not a key |
| | 94 | |
| | 95 | === Attempt 3: venue_id⁺ === |
| | 96 | |
| | 97 | || Derived Attributes || |
| | 98 | || venue_name, venue_type, venue_capacity || |
| | 99 | |
| | 100 | ❌ Missing user, wedding, booking |
| | 101 | → Not a key |
| | 102 | |
| | 103 | === Attempt 4: booking_id⁺ === |
| | 104 | |
| | 105 | || Derived Attributes || |
| | 106 | || venue_id, wedding_id, booking_date, start_time, end_time || |
| | 107 | || venue_name, venue_type, venue_capacity || |
| | 108 | || wedding_date, wedding_budget, user_id || |
| | 109 | || user_first_name, user_last_name, user_email || |
| | 110 | |
| | 111 | ✅ booking_id⁺ = ALL ATTRIBUTES |
| | 112 | |
| | 113 | Thus: |
| | 114 | |
| | 115 | || Candidate Key || |
| | 116 | || booking_id || |
| | 117 | |
| | 118 | To uniquely identify a tuple in R, the following composite key is required: |
| | 119 | |
| | 120 | || Candidate Key || |
| | 121 | || (user_id, wedding_id, venue_id, booking_date) || |
| | 122 | |
| | 123 | This confirms that the initial relation has a composite primary key, which leads to partial dependencies. |