0 valutazioniIl 0% ha trovato utile questo documento (0 voti)
13 visualizzazioni1 pagina
1. The document discusses fourth normal form (4NF) and describes an example table, salesperson_skill, that has two independent many-to-many relationships - between salesperson and sales_skill, and between salesperson and technical_skill.
2. It notes that this violates 4NF and the relationships should be separated into two tables: salesperson_sales_skill and salesperson_technical_skill.
3. Doing so eliminates issues around how to properly handle rows in the original salesperson_skill table given the different numbers of sales and technical skills a salesperson could have.
1. The document discusses fourth normal form (4NF) and describes an example table, salesperson_skill, that has two independent many-to-many relationships - between salesperson and sales_skill, and between salesperson and technical_skill.
2. It notes that this violates 4NF and the relationships should be separated into two tables: salesperson_sales_skill and salesperson_technical_skill.
3. Doing so eliminates issues around how to properly handle rows in the original salesperson_skill table given the different numbers of sales and technical skills a salesperson could have.
1. The document discusses fourth normal form (4NF) and describes an example table, salesperson_skill, that has two independent many-to-many relationships - between salesperson and sales_skill, and between salesperson and technical_skill.
2. It notes that this violates 4NF and the relationships should be separated into two tables: salesperson_sales_skill and salesperson_technical_skill.
3. Doing so eliminates issues around how to properly handle rows in the original salesperson_skill table given the different numbers of sales and technical skills a salesperson could have.
salesperson_id INTEGER NOT NULL REFERENCES salesperson, sales_skill_id INTEGER NULL REFERENCES sales_skill, PRIMARY KEY ( salesperson_id, sales_skill_id ) ); In practice its hard to tell the difference between Third Normal Form and Boyce-Codd Normal Form. If you transform a table into Third Normal Form, the chances are good that it will also be in Boyce-Codd Normal Form because you removed all the redundancies, regardless of the subtle differences in the definitions. In fact, chances are your Third Normal Form database design will also be in Fourth and Fifth Normal Form. The next two sections discuss the rare situations where Fourth and Fifth Normal Forms differ from Third.
1.16.5 Fourth Normal Form
Fourth Normal Form (4NF) eliminates multiple independent many-to-many relationships in the same table. In the following example the salesperson_skill table represents two many-to-many relationships. First, there is a relationship where one salesperson may have many sales skills, and conversely, one sales skill can be shared by multiple salespersons. Second, there is a many-to-many relationship between salesperson and technical skill. These two relationships are independent; a salespersons technical and sales skills do not depend on one another, at least as far as this design is concerned. CREATE TABLE salesperson ( salesperson_id INTEGER NOT NULL PRIMARY KEY, salesperson_name VARCHAR ( 100 ) NOT NULL );
CREATE TABLE sales_skill (
sales_skill_id INTEGER NOT NULL PRIMARY KEY, description LONG VARCHAR );
CREATE TABLE technical_skill (
technical_skill_id INTEGER NOT NULL PRIMARY KEY, description LONG VARCHAR );
CREATE TABLE salesperson_skill (
salesperson_id INTEGER NOT NULL REFERENCES salesperson, sales_skill_id INTEGER NOT NULL REFERENCES sales_skill, technical_skill_id INTEGER NOT NULL REFERENCES technical_skill, PRIMARY KEY ( salesperson_id, sales_skill_id, technical_skill_id ) ); It is not clear how the rows in salesperson_skill should be filled when a sales- person has different numbers of sales and technical skills. Should special blank values be used for the missing skills, should disjointed rows be filled with either sales or technical skills but not both, or should a cross product of all combinations of sales and technical skills be constructed? All these alternatives have problems with redundancy or complex rules for updating, or both. The solution is to replace salesperson_skill with two separate tables, as follows: CREATE TABLE salesperson_sales_skill ( salesperson_id INTEGER NOT NULL REFERENCES salesperson, sales_skill_id INTEGER NOT NULL REFERENCES sales_skill, PRIMARY KEY ( salesperson_id, sales_skill_id ) );
Maxwell Flitton - Rust Web Programming - A Hands-On Guide To Developing, Packaging, and Deploying Fully Functional Rust Web Applications,-Packt Publishing (2023)