following table – the street name, city and the state are unbreakably bound to their zip
SQL
11
);
The dependency between the zip code and the address is called as a transitive dependency.
To comply with the third normal form, all you need to do is to move the Street, City and
the State fields into their own table, which you can call as the Zip Code table.
CREATE TABLE ADDRESS(
ZIP VARCHAR(12),
STREET VARCHAR(200),
CITY VARCHAR(100),
STATE VARCHAR(100),
PRIMARY KEY (ZIP)
);
The next step is to alter the CUSTOMERS table as shown below.
CREATE TABLE CUSTOMERS(
CUST_ID INT NOT NULL,
CUST_NAME VARCHAR (20) NOT NULL,
DOB DATE,
ZIP VARCHAR(12),
EMAIL_ID VARCHAR(256),
PRIMARY KEY (CUST_ID)
);
The advantages of removing transitive dependencies are mainly two-fold. First, the
amount of data duplication is reduced and therefore your database becomes smaller.
The second advantage is data integrity. When duplicated data changes, there is a big risk
of updating only some of the data, especially if it is spread out in many different places in
the database.
For example, if the address and the zip code data were stored in three or four different
tables, then any changes in the zip codes would need to ripple out to every record in those
three or four tables.
SQL
12
There are many popular RDBMS available to work with. This tutorial gives a brief overview
of some of the most popular RDBMS’s. This would help you to compare their basic features.
MySQL
MySQL is an open source SQL database, which is developed by a Swedish company –
MySQL AB. MySQL is pronounced as "my ess-que-ell," in contrast with SQL, pronounced
"sequel."
MySQL is supporting many different platforms including Microsoft Windows, the major
Linux distributions, UNIX, and Mac OS X.
MySQL has free and paid versions, depending on its usage (non-commercial/commercial)
and features. MySQL comes with a very fast, multi-threaded, multi-user and robust SQL
database server.
Dostları ilə paylaş: