Chapter 4. Creating RDBMS Objects

By definition, a database is a collection of objects and processes that manage these objects. Before you can start doing anything with a database, you have to design it and then create its objects. The database design is a separate (but related to) SQL topic — we give a crash course in RDBMS design basics in Appendix C. This chapter is about creating objects in a relational database.

Note

To be able to create database objects, you must have sufficient (implementation specific) security privileges. See Chapter 12, "SQL and RDBMS Security" for a detailed discussion of SQL security.

Tables

Tables are the central and the most important objects in any relational database. The primary purpose of any database is to hold data that is logically stored in tables.

One of the relational database design principles is that each table holds information about one specific type of thing, or entity. For example, a CUSTOMER table would contain data about customers only, not about the products they ordered, invoices issued to them, or salesmen who placed orders for them. In the ACME database, the CUSTOMER table doesn't even have customers' addresses and phone numbers because those are separate entities represented by ADDRESS and PHONE tables respectively.

Rows (sometimes also called records) are horizontal slices of data — each row contains data about one entity item. A row from the CUSTOMER table contains information about one single customer, a row from the ORDER_HEADER ...

Get SQL Bible, Second 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.