Changes between Initial Version and Version 1 of Proof of 2N


Ignore:
Timestamp:
01/27/26 23:57:58 (13 days ago)
Author:
213087
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Proof of 2N

    v1 v1  
     1== Second Normal Form (2NF) – Detailed Explanation ==
     2
     3Second Normal Form is the first place where real normalization starts.
     4The goal of 2NF is to remove partial dependencies, which cause redundancy and anomalies.
     5
     6=== Formal Definition of 2NF ===
     7
     8**A relation R is in Second Normal Form (2NF) if and only if:
     9
     10*R is already in First Normal Form (1NF)
     11
     12*No non-key attribute is functionally dependent on only a part of a composite primary key**
     13
     14Formally:
     15
     16**If
     17X → A is a functional dependency in R,
     18and X is a proper subset of a candidate key,
     19then A must be a prime attribute, otherwise 2NF is violated.**
     20
     21=== Context: Why 2NF Is Relevant in Wedding Planner ===
     22
     23In the Wedding Planner system, multiple real-world entities appear together:
     24
     25***Users, Weddings, Venues, Venue bookings**
     26
     27When all of these are stored in one relation, identification requires more than one attribute, which creates a composite key.
     28
     29=== Initial Relation Before 2NF ===
     30
     31|| Relation ||
     32|| R(user_id, user_first_name, user_last_name, user_email, wedding_id, wedding_date, wedding_budget, venue_id, venue_name, venue_type, venue_capacity, booking_id, booking_date, start_time, end_time) ||
     33
     34This relation is already in 1NF (all values are atomic), but that does not guarantee correctness.
     35
     36=== Candidate Key Identification (Required for 2NF) ===
     37
     38To analyze 2NF, we must first know the candidate key.
     39
     40A tuple in R is uniquely identified only when all business dimensions are fixed:
     41
     42|| Candidate Key ||
     43|| (user_id, wedding_id, venue_id, booking_date) ||
     44
     45
     46== Justification:
     47
     48*A user can manage multiple weddings
     49
     50*A wedding can book multiple venues
     51
     52*A venue can be booked on different dates
     53
     54*Only the full combination guarantees uniqueness
     55
     56**This means the primary key is composite, which makes partial dependency possible.**
     57
     58=== Functional Dependencies in the Relation ===
     59
     60|| ID || Functional Dependency || Meaning in Wedding Planner ||
     61|| FD1 || user_id → user_first_name, user_last_name, user_email || User data depends only on the user
     62|| FD2 || wedding_id → wedding_date, wedding_budget || Wedding data depends only on the wedding
     63|| FD3 || venue_id → venue_name, venue_type, venue_capacity || Venue data depends only on the venue
     64|| FD4 || booking_id → venue_id, wedding_id, booking_date, start_time, end_time || Booking defines reservation details ||
     65
     66=== Proof of Partial Dependencies (2NF Violation) ===
     67
     68A partial dependency exists when:
     69
     701.It's a non-key attribute
     71
     722.Depends on part of the composite key
     73
     743.Instead of the entire key
     75
     76=== Partial Dependency Table ===
     77
     78|| Non-Key Attribute || Depends On || Why This Violates 2NF ||
     79|| user_first_name || user_id || user_id is only part of the key
     80|| user_email || user_id || Does not depend on wedding or venue
     81|| wedding_date || wedding_id || Independent of user and venue
     82|| venue_name || venue_id || Independent of wedding and user ||
     83
     84Each of these attributes depends on only one component of the composite key.
     85
     86**📌 Conclusion:
     87The relation violates Second Normal Form**
     88
     89=== Why This Is a Problem ===
     90
     91|| Problem || Example ||
     92|| Redundancy || User name repeated for every booking
     93|| Update anomaly || Changing email requires multiple updates
     94|| Insertion anomaly || Cannot store venue without booking
     95|| Deletion anomaly || Deleting booking deletes venue data ||
     96
     97These issues are exactly what 2NF is designed to prevent.
     98
     99=== Decomposition Strategy for 2NF ===
     100
     101To reach 2NF, we must:
     102
     1031.Separate attributes that depend on different parts of the key
     104
     1052.Create new relations where each non-key attribute depends on the full primary key
     106
     107=== Decomposition into 2NF Relations ===
     108
     109=== USER ===
     110
     111|| Table || Primary Key || Attributes ||
     112|| user || user_id || user_first_name, user_last_name, user_email ||
     113
     114Why this works:
     115
     116user_id → all user attributes
     117
     118No partial dependency is possible
     119
     120=== WEDDING ===
     121
     122|| Table || Primary Key || Attributes ||
     123|| wedding || wedding_id || wedding_date, wedding_budget, user_id ||
     124
     125Why this works:
     126
     127wedding_id → wedding_date, wedding_budget
     128
     129user_id is a foreign key, not a determinant
     130
     131=== VENUE ===
     132
     133|| Table || Primary Key || Attributes ||
     134|| venue || venue_id || venue_name, venue_type, venue_capacity ||
     135
     136Why this works:
     137
     138venue_id fully determines all venue attributes
     139
     140=== VENUE_BOOKING ===
     141
     142|| Table || Primary Key || Attributes ||
     143|| venue_booking || booking_id || venue_id, wedding_id, booking_date, start_time, end_time ||
     144
     145Why this works:
     146
     147booking_id uniquely identifies a reservation
     148
     149All attributes depend on booking_id
     150
     151=== Verification That 2NF Is Achieved ===
     152
     153For each table:
     154
     155|| Table || Full Dependency Check ||
     156|| user || All attributes depend on user_id
     157|| wedding || All attributes depend on wedding_id
     158|| venue || All attributes depend on venue_id
     159|| venue_booking || All attributes depend on booking_id ||
     160
     161There are:
     162
     163No composite keys with partial dependencies
     164
     165No attributes depending on subsets of keys
     166
     167✅ All relations satisfy Second Normal Form
     168
     169=== Key Insight ===
     170
     171**Second Normal Form is achieved not by removing composite keys, but by ensuring that no non-key attribute depends on only part of a composite key.
     172
     173In the Wedding Planner system, this required separating user, wedding, venue, and booking into independent relations.**