TAILIEUCHUNG - SQL Antipatterns- P7

Tham khảo tài liệu 'sql antipatterns- p7', công nghệ thông tin, cơ sở dữ liệu phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | What Is Normalization 301 Second Normal Form bug_id tag tagger coiner Hl 1234 crash Larry Shemp 3456 printing Larry Shemp 3456 crash Moe Shemp 5678 report Moe Shemp 5678 crash Larry Shemp 5678 data Moe Shemp bug_id tag tagger coiner 1234 crash Larry Shemp 3456 printing Larry Shemp 3456 crash Moe Shemp 5678 report Moe Shemp 5678 crash Larry Curly 5678 data Moe Shemp -J BugsTags Redundancy Anomaly bug_id tag tagger tag coiner 1234 crash Larry crash Shemp 3456 printing Larry printing Shemp 3456 crash Moe I report Shemp 5678 report Moe data Shemp 5678 crash Larry 5678 data Moe - BugsTags Tags Figure Redundancy vs. second normal form Third Normal Form In the Bugs table you might want to store the email of the engineer working on the bug. Download Normalization CREATE TABLE Bugs bug_id SERIAL PRIMARY KEY assigned_to BIGINT assigned_email VARCHAR 100 FOREIGN KEY assigned_to REFERENCES Accounts account_id However the email is an attribute of the assigned engineer s account it s not strictly an attribute of the bug. It s redundant to store the email Repor erratum this copy is printing May 2010 What Is Normalization 302 bug_id assigned_to assigned_email 1234 Larry larry@ 3456 Moe moe@ 5678 Moe moe@ v Redundancy bug id assigned to 1234 Larry 3456 Moe 5678 Moe assigned email larry@ moe@ curly@ Anomaly Third Normal Form _ Bugs bug_id assigned_to account_id email 1234 Larry Larry larry@ 3456 Moe Moe moe@ 5678 Moe V Bugs Accounts Figure Redundancy vs. third normal form in this way and we risk anomalies like in the table that fails second normal form. in the example for second normal form the offending column is related to at least part of the compound primary key. In this example that violates third normal form the offending column doesn t correspond to the primary key at all. To fix this we need to put the email address into the Accounts table. .

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.