0% found this document useful (0 votes)
41 views

Chapter Summary

The document describes how to normalize a salesperson, company, and product line database into third normal form. It creates tables for salesperson-company assignments, company product lines, and salesperson product lines, and provides example INSERT statements to populate the tables. A SELECT statement is then used to reconstruct the original salesperson-company-line table from the normalized tables.

Uploaded by

Nishki Gejmer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Chapter Summary

The document describes how to normalize a salesperson, company, and product line database into third normal form. It creates tables for salesperson-company assignments, company product lines, and salesperson product lines, and provides example INSERT statements to populate the tables. A SELECT statement is then used to reconstruct the original salesperson-company-line table from the normalized tables.

Uploaded by

Nishki Gejmer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Chapter 1: Creating 47

CREATE TABLE company_line (


company_id VARCHAR ( 10 ) NOT NULL REFERENCES company,
product_line_id VARCHAR ( 10 ) NOT NULL REFERENCES product_line,
PRIMARY KEY ( company_id, product_line_id ) );

CREATE TABLE salesperson_line (


salesperson_id INTEGER NOT NULL REFERENCES salesperson,
product_line_id VARCHAR ( 10 ) NOT NULL REFERENCES product_line,
PRIMARY KEY ( salesperson_id, product_line_id ) );
Here is how the three new tables can be filled, with a SELECT to rebuild the
original table including the row showing that yes, salesperson 2 does in fact
handle cars for Acme:
INSERT salesperson_company VALUES ( 1, 'Acme' );
INSERT salesperson_company VALUES ( 2, 'Acme' );
INSERT salesperson_company VALUES ( 2, 'Best' );
INSERT company_line VALUES ( 'Acme', 'cars' );
INSERT company_line VALUES ( 'Acme', 'trucks' );
INSERT company_line VALUES ( 'Best', 'cars' );
INSERT salesperson_line VALUES ( 1, 'cars' );
INSERT salesperson_line VALUES ( 2, 'cars' );
INSERT salesperson_line VALUES ( 2, 'trucks' );

SELECT DISTINCT
salesperson_company.salesperson_id,
company_line.company_id,
salesperson_line.product_line_id
FROM salesperson_company
JOIN company_line
ON salesperson_company.company_id = company_line.company_id
JOIN salesperson_line
ON salesperson_company.salesperson_id = salesperson_line.salesperson_id
AND company_line.product_line_id = salesperson_line.product_line_id;
Tables requiring a separate effort to reach Fifth Normal Form are extremely
rare. In this example, if the special business rule was not in effect the original
salesperson_company_line table would be the correct choice because it imple-
ments a three-way many-to-many relationship among salesperson, company,
and product line... and it would already be in Fifth Normal Form. In most cases,
once youve reached Third Normal Form, youve reached Boyce-Codd, Fourth,
and Fifth Normal Forms as well.

1.17 Chapter Summary


This chapter described how to create the five different types of tables in SQL
Anywhere 9: global permanent, remote, proxy, global temporary, and local tem-
porary. Also discussed were the basic column data types; column properties like
COMPUTE and DEFAULT; and column and table constraints such as CHECK,
PRIMARY KEY, foreign key, and UNIQUE. The 12 rules for relational data-
bases and the six normal forms of good database design were explained.
The next chapter moves on to the second step in the life cycle of a database:
inserting rows.

You might also like