June 2010
Intermediate to advanced
328 pages
7h 51m
English
When a column in a table has a single value, the design is straightforward: you can choose an SQL data type to represent a single instance of that value, for example an integer, date, or string. But how do you store a collection of related values in a column?
In the example bug-tracking database, we might associate a product with a contact using an integer column in the Products table. Each account may have many products, and each product references one contact, so we have a many-to-one relationship between products and accounts.
| Jaywalking/obj/create.sql | |
| | CREATE TABLE Products ( |
| | product_id SERIAL PRIMARY KEY, |
| | product_name VARCHAR(1000), |
| | account_id BIGINT UNSIGNED, |
| | -- . . . |
| | |
Read now
Unlock full access