(1 of 2)
...
1
HRO
baseball gloves
250.00
case
10 gloves/case
HSK
800.00
SMT
450.00
2
baseball
126.00
24/case
3
baseball bat
240.00
12/case
4
football
960.00
480.00
5
NRG
tennis racquet
28.00
each
313
ANZ
swim cap
60.00
12/box
A table represents all that is known about one entity, one type of thing that the database describes. The example table, stock, represents all that is known about the merchandise that is stocked by a sporting-goods store. Other tables in the demonstration database represent such entities as customer and orders. Think of a database as a collection of tables. To create a database is to create a set of tables. The right to query or modify tables can be controlled on a table-by-table basis, so that some users can view or modify some tables but not others. Columns In a traditional relational model, each column of a table stands for one attribute, which is one characteristic, feature, or fact that is true of the subject of the table. For example, the stock table has separate columns for each of the following facts about items of merchandise: stock numbers, manufacturer codes, descriptions, prices, and units of measure. In the object-relational model, each column of a table can stand for one attribute or multiple attributes. For example, you might create a single column that contains all the address-related attributes. Such a column might contain distinct attributes for street, city, state, and zip code data. For information about creating columns that contain multiple attributes, see "Using a Named Row Type to Create a Column". A column can also stand for a collection of values within a single row of a table. For information about creating columns that contain collections, see "Collection Data Types".
Rows In an object-relational model, each row of a table stands for one instance of the subject of the table, which is one particular example of that entity. Each row of the stock table stands for one item of merchandise that the sporting-goods store sells. Tables, Rows, and Columns Now you understand that the object-relational model is a way of organizing data to reflect the world. It uses the following simple corresponding relationships:
Now you understand that the object-relational model is a way of organizing data to reflect the world. It uses the following simple corresponding relationships:
table = entity
A table represents all that the database knows about one subject or kind of thing.
column = attribute(s)
A column represents one or more features, characteristics, or facts that is true of the table subject.
row = instance
A row represents one individual instance of the table subject.
Operations on Tables Because a database is really a collection of tables, database operations are operations on tables. The relational model supports three fundamental operations, two of which are shown in the following illustration. (All three operations are defined in more detail, with many examples, in Chapter 2, "Composing Simple SELECT Statements," and Chapter 3, "Composing Advanced SELECT Statements.")
When you select data from a table, you are choosing certain rows and ignoring others. For example, you can query the stock table by asking the database management system to "select all rows in which the manufacturer code is HRO and the unit price is between 100.00 and 200.00." When you project from a table, you are choosing certain columns and ignoring others. For example, you can query the stock table by asking the database management system to "project the stock_num, unit_price, and unit_descr columns." A table contains information about only one entity; when you want information about multiple entities, you must join their tables. You can join tables in many ways. (The join operation is the subject of Chapter 3, "Composing Advanced SELECT Statements.")
Figure 1-4 Illustration of Selection and Projection