Planning Tables

Creating a table involves a series of steps that begins with design and ends with issuing a SQL command. Following is an outline of the process for creating tables without any SQL-92 constraints. It assumes you've already designed and normalized your database and therefore know which columns will be in each table.

1.
Decide on the datatype (and length, precision, and scale, if required) of each column.
2.
Decide which columns should accept null values and which should not.
3.
Decide which columns need to be unique, that is, cannot allow duplicate values. (In a system that doesn't use constraints, you'll enforce uniqueness with indexes, discussed in this chapter and in Chapter 10. Information on PRIMARY KEY and UNIQUE constraints ...

Get Practical SQL Handbook, The: Using SQL Variants, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.