Table definitions for 3rd Normal Form
Recall the definition of the school table from the previous exercise:
CREATE TABLE school (
id serial PRIMARY KEY,
name VARCHAR(100) NOT NULL,
street_address VARCHAR(100) NOT NULL,
city VARCHAR(50) NOT NULL,
state VARCHAR(50) NOT NULL,
zip_code INTEGER NOT NULL
)
We can define a new table called zip to help satisfy 3rd Normal Form.
Bu egzersiz
Creating PostgreSQL Databases
kursunun bir parçasıdırEgzersiz talimatları
- Add a
PRIMARY KEYnamedcodeto complete the definition of theziptable. - Update the definition of
schoolto satisfy 3NF.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
-- Complete the definition of the table for zip codes
CREATE TABLE zip (
___ INTEGER ___ ___,
city VARCHAR(50) NOT NULL,
state VARCHAR(50) NOT NULL
);
-- Complete the definition of the "zip_code" column
CREATE TABLE school (
id serial PRIMARY KEY,
name VARCHAR(100) NOT NULL,
street_address VARCHAR(100) NOT NULL,
zip_code INTEGER REFERENCES ___(___)
);