-
Notifications
You must be signed in to change notification settings - Fork 0
Data Normalization
Nantawan Paramapooti edited this page Nov 10, 2024
·
9 revisions
*data instances in the following examples are abstract values for demonstration, may not accurately reflects project's actual instances.
| post_id | user_id | p_content | timestamp |
|---|---|---|---|
| 1 | 1 | "Hello" | 2024-11-10 |
| 2 | 2 | "Learning NF Forms" | 2024-11-11 |
| 3 | 1 | "Normalization Rocks" | 2024-11-12 |
- Each attribute (post_id, user_id, p_content, timestamp) holds only indivisible values.
- Since post_id is the primary key, all non-key attributes (user_id, p_content, timestamp) are fully dependent on post_id.
- There are no dependencies between non-key attributes; therefore, no transitive dependency exists.
| user_id | follower_id |
|---|---|
| 1 | 2 |
| 2 | 3 |
| 3 | 1 |
- Both attributes (user_id, follower_id) hold only indivisible values.
- The combination of user_id and follower_id forms a composite primary key, and there is no partial dependency.
- There are no additional non-key attributes, so no transitive dependency exists.
| blocker_id | blocked_id |
|---|---|
| 1 | 3 |
| 2 | 1 |
| 3 | 2 |
- Each attribute (blocker_id, blocked_id) is atomic.
- The combination of blocker_id and blocked_id forms a composite primary key, and all attributes are fully dependent on it.
- No non-key attributes are present, so no transitive dependency exists.
| user_id | username | password | name | bio | |
|---|---|---|---|---|---|
| 1 | user1 | user1@email.com | pass123 | John Doe | "Developer" |
| 2 | user2 | user2@email.com | pass456 | Jane Smith | "Data Scientist" |
| 3 | user3 | user3@email.com | pass789 | Bob Brown | "AI Enthusiast" |
- Each attribute (user_id, username, email, password, name, bio) holds atomic values.
- user_id is the primary key, and all other attributes (username, email, password, name, bio) are fully dependent on user_id.
- There are no transitive dependencies among non-key attributes.
| user_id | chat_id |
|---|---|
| 1 | 1 |
| 2 | 1 |
| 3 | 2 |
- Both attributes (user_id, chat_id) hold atomic values.
- The composite primary key (user_id, chat_id) fully determines all non-key attributes.
- There are no non-key attributes, so no transitive dependency exists.
| chat_id | chat_name |
|---|---|
| 1 | "General" |
| 2 | "Project A" |
| 3 | "Random Chat" |
- Each attribute (chat_id, chat_name) is atomic.
- chat_id is the primary key, and chat_name is fully dependent on chat_id.
- There are no transitive dependencies among non-key attributes.
| message_id | user_id | chat_id | ms_content | timestamp |
|---|---|---|---|---|
| 1 | 1 | 1 | "Hello World" | 2024-11-10 |
| 2 | 2 | 1 | "Hi Everyone" | 2024-11-11 |
| 3 | 3 | 2 | "Project Update" | 2024-11-12 |
- Each attribute (message_id, user_id, chat_id, ms_content, timestamp) holds atomic values.
- message_id is the primary key, and all other attributes are fully dependent on message_id.
- There are no transitive dependencies among non-key attributes.
| comment_id | user_id | post_id | c_content | timestamp |
|---|---|---|---|---|
| 1 | 1 | 1 | "Nice Post" | 2024-11-10 |
| 2 | 2 | 1 | "Great info!" | 2024-11-11 |
| 3 | 3 | 2 | "Very helpful." | 2024-11-12 |
- Each attribute (comment_id, user_id, post_id, c_content, timestamp) is atomic.
- comment_id is the primary key, and all other attributes depend fully on comment_id.
- There are no transitive dependencies among non-key attributes.
| tag_id | tag_content |
|---|---|
| 1 | "coding" |
| 2 | "database" |
| 3 | "AI" |
- Each attribute (tag_id, tag_content) is atomic.
- tag_id is the primary key, and tag_content is fully dependent on tag_id.
- There are no transitive dependencies among non-key attributes.
| tag_id | post_id |
|---|---|
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
- Both attributes (tag_id, post_id) hold atomic values.
- The composite primary key (tag_id, post_id) fully determines all non-key attributes.
- There are no non-key attributes, so no transitive dependency exists.
| like_id | user_id | post_id |
|---|---|---|
| 1 | 1 | 1 |
| 2 | 2 | 2 |
| 3 | 3 | 3 |
- Each attribute (like_id, user_id, post_id) is atomic.
- like_id is the primary key, and all other attributes are fully dependent on it.
- There are no transitive dependencies among non-key attributes.
| share_id | user_id | post_id | share_type |
|---|---|---|---|
| 1 | 1 | 1 | "public" |
| 2 | 2 | 1 | "private" |
| 3 | 3 | 2 | "public" |
- Each attribute (share_id, user_id, post_id, share_type) is atomic.
- share_id is the primary key, and all other attributes are fully dependent on it.
- There are no transitive dependencies among non-key attributes.
All relations are already in its 3NF form from the UML design, no further changes needed.