Changes between Version 1 and Version 2 of Proof of Candidate Key


Ignore:
Timestamp:
05/08/26 20:13:11 (3 weeks ago)
Author:
211171
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Proof of Candidate Key

    v1 v2  
    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.
     1= Proof of Candidate Key =
     2
     3== Definition ==
     4
     5A set of attributes X is a candidate key if:
     6
     7X⁺ = R
     8X is minimal
     9
     10The closure X⁺ is computed by repeatedly applying functional dependencies until no additional attributes can be derived.
     11
     12== Step 1 – Testing Single Attribute Candidate Keys ==
     13
     14=== Attempt 1 ===
     15
     16K = {attendance_id}
     17
     18=== Closure ===
     19
     20(attendance_id)⁺ gives:
     21
     22attendance_status
     23table_number
     24guest_id
     25event_id
     26
     27Using additional dependencies:
     28
     29event_id → event_type, wedding_id
     30guest_id → guest_first_name, guest_last_name, rsvp_status, wedding_id
     31wedding_id → date, budget, notes, user_id
     32user_id → first_name, last_name, email, phone_number, gender, birthday
     33
     34=== Missing Dependencies ===
     35
     36The closure still does NOT determine:
     37
     38venue booking information
     39photographer booking information
     40band booking information
     41registrar booking information
     42priest and church information
     43
     44Therefore:
     45
     46(attendance_id)⁺ ≠ R
     47
     48Conclusion:
     49
     50attendance_id is NOT a candidate key.
     51
     52== Step 2 – Testing Two Attributes ==
     53
     54K = {attendance_id, priest_id}
     55
     56=== Closure ===
     57
     58Additional attributes derived:
     59
     60priest_name
     61priest_contact
     62church_id
     63church_name
     64church_location
     65
     66=== Missing Dependencies ===
     67
     68Still missing:
     69
     70venue booking information
     71photographer booking information
     72band booking information
     73registrar booking information
     74
     75Therefore:
     76
     77(attendance_id, priest_id)⁺ ≠ R
     78
     79Conclusion:
     80
     81K is NOT a candidate key.
     82
     83== Step 3 – Testing Three Attributes ==
     84
     85K = {
     86attendance_id,
     87venue_booking_id,
     88photographer_booking_id
     89}
     90
     91=== Closure ===
     92
     93Additional attributes derived:
     94
     95venue information
     96photographer information
     97wedding information
     98user information
     99
     100=== Missing Dependencies ===
     101
     102Still missing:
     103
     104band booking information
     105registrar booking information
     106priest/church information
     107
     108Therefore:
     109
     110K⁺ ≠ R
     111
     112Conclusion:
     113
     114K is NOT a candidate key.
     115
     116== Step 4 – Testing Larger Attribute Sets ==
     117
     118K = {
     119attendance_id,
     120priest_id,
     121venue_booking_id,
     122band_booking_id
     123}
     124
     125=== Missing Dependencies ===
     126
     127Still missing:
     128
     129photographer booking information
     130registrar booking information
     131
     132Therefore:
     133
     134K⁺ ≠ R
     135
     136Conclusion:
     137
     138K is NOT a candidate key.
     139
     140== Step 5 – Including All Booking Branches ==
     141
     142K = {
     143attendance_id,
     144venue_booking_id,
     145photographer_booking_id,
     146band_booking_id,
     147registrar_booking_id
     148}
     149
     150=== Missing Dependencies ===
     151
     152Still missing:
     153
     154priest information
     155church information
     156
     157Therefore:
     158
     159K⁺ ≠ R
     160
     161Conclusion:
     162
     163K is NOT a candidate key.
     164
     165== Step 6 – Final Candidate Key ==
     166
     167K = {
     168attendance_id,
     169venue_booking_id,
     170photographer_booking_id,
     171band_booking_id,
     172registrar_booking_id,
     173priest_id
     174}
     175
     176=== Closure ===
     177
     178Using all functional dependencies:
     179
     180attendance branch is determined
     181event branch is determined
     182guest branch is determined
     183wedding branch is determined
     184venue booking branch is determined
     185photographer booking branch is determined
     186band booking branch is determined
     187registrar booking branch is determined
     188priest branch is determined
     189church branch is determined
     190
     191No attributes remain undetermined.
     192
     193Therefore:
     194
     195K⁺ = R
     196
     197Conclusion:
     198
     199K is a candidate key.
     200
     201== Minimality Proof ==
     202
     203A candidate key must be minimal.
     204
     205Removing any attribute from K causes loss of at least one independent entity branch:
     206
     207|| Removed Attribute || Lost Information ||
     208|| attendance_id || attendance branch ||
     209|| venue_booking_id || venue booking branch ||
     210|| photographer_booking_id || photographer booking branch ||
     211|| band_booking_id || band booking branch ||
     212|| registrar_booking_id || registrar booking branch ||
     213|| priest_id || priest/church branch ||
     214
     215Therefore every attribute in K is necessary.
     216
     217== Why church_id Is Not Included ==
     218
     219Suppose we define:
     220
     221K = {
     222attendance_id,
     223venue_booking_id,
     224photographer_booking_id,
     225band_booking_id,
     226registrar_booking_id,
     227priest_id,
     228church_id
     229}
     230
     231This violates minimality because:
     232
     233priest_id → church_id
     234
     235church_id is already derivable from priest_id.
     236
     237Therefore church_id is redundant.
     238
     239The resulting set would be a superkey, NOT a candidate key.
     240
     241== Final Candidate Key ==
     242
     243K = {
     244attendance_id,
     245venue_booking_id,
     246photographer_booking_id,
     247band_booking_id,
     248registrar_booking_id,
     249priest_id
     250}
     251
     252This key:
     253
     254Determines all attributes of R
     255Is minimal
     256Satisfies the formal definition of a candidate key