1. The Relational Data Model
You don't need to be a database designer to use SQL successfully. However, you do need to know a bit about how relational databases are structured and how to manipulate those structures. This chapter therefore will acquaint you with the basic elements of the relational data model and its terminology. We'll finish by looking at the design of the sample database used throughout this book. 1
1If you have been reading this book's companion volume, Relational Database Design and Implementation Clearly Explained, then you will be familiar with the concepts presented in this chapter. You can therefore skip to the last section of this chapter to review the design of the sample database.
Schemas and Entities
A database is a place where we store data, but there is more to it than that: We also store information about the relationships between pieces of data. The organization of a database is a logical concept rather than a physical one. Yes, there are files that store the data in a database, but the physical structure of those files usually isn't a concern for those who use the data.
The software that organizes, stores, retrieves, and analyzes database data is known as a database management system (DBMS). It isolates the user from the physical data storage mechanisms and structures and lets the user work with data in terms of the logical structure of the data.
Relational Data Model Origins
The theory of the relational data model was developed by Edgar (E. F.) Codd and introduced to the world in a paper published in 1970. 1 Codd continued to refine the model throughout his life, in 1985 publishing 12 rules to which relational DBMSs should adhere. 2 At that time, no DBMS met the rules and some commercially successful products met none of them. Eventually, Codd wrote a book that contained 330 rules. 3 He felt that DBMSs had met most of the original 12 rules and he wanted to give developers something to strive for.
1Codd, E.F. (1970). “A Relational MOdel for Large Shared Data Banks”, Communications of the ACM, 13 (6): pp. 377-387.
2Codd, E.F. (1985). “Is Your DBMS Really Relational?”, ComputerWorld, 14 October, and “Does Your DBMS Run By the Rules?” ComputerWorld, 21 October.
3Codd, E.F. (1990). The Relational Model for Database Management, 2nd ed. Addison Wesley.
The overall logical plan of a database is known as a schema. A schema has two types of elements:
◊ Entities: An entity is something about which we store data, such as a customer or a product or an order for a product. Entities are described by pieces of data known as attributes. When we have a collection of data for all the attributes of an entity, we say we have an occurrence of the entity. Databases actually store occurrences of entities. Schemas show us what entities will be in the database and what attributes are used to represent those entities.
◊ Relationships: Relationships define how entities interact. For example, a customer entity is typically related to many order entities. There are three types of relationships, all of which we will discuss shortly.
The most important thing to keep in mind is that a schema shows the logical plan for a database, what entities and relationships could possibly be stored. However, inside the real-world database, we have many occurrences of many entities, each represented by descriptive data. We may not have occurrences of every entity in the schema or we may have thousands (even hundreds of thousands) of occurrences of entities.
Relations and Tables
A relational database takes its name from the structure used to represent an entity: a two-dimensional table with special characteristics taken from mathematical set theory, where such a structure is known as a relation. 2 To begin, let's look at the simple relation in Figure 1-1. At first glance, the relation looks like any table, but unlike other tables you may have encountered (for example, rectangular areas of spreadsheets), it has some very specific characteristics.
2Don't let anyone try to convince you that a relational database is called so because there are “relationships between files.” That is just plain wrong.
B9780123756978500017/f01-01-9780123756978.jpg is missing
Figure 1-1
A simple customer relation
Columns and Rows
A relation is a two-dimensional table with no repeating groups. That means that if you look at the intersection of a column and a row, there will be only one value. What you see in Figure 1-2is certainly a table, but it isn't a relation. Why? Because there are multiple values in some of the rows in the Children column. In contrast, Figure 1-1 is a legal relation.
Note: Although the official name of the two-dimensional “thing” we have been discussing is “relation,” most people consider the word “table” to be synonymous and we will use both terms interchangeably throughout this book.
B9780123756978500017/f01-02-9780123756978.jpg is missing
Figure 1-2
A table that isn't a relation
A relation has a name that is unique within its schema. Each column (or attribute) in a relation also has a name, but in this case, the name needs to be unique only within the table. In fact, as you will see shortly, there are times when you actually want to have columns with the same names in multiple tables.
In a well-designed relational database, each table represents an entity. We often document entities (and, as you will see, the relationships among them) in a diagram known as an entity-relationship diagram (ERD). There are many ways to draw ERDs, each of which can convey just about the same information. The particular style we'll be using in this book is known as the information engineering (IE) style. An entity is represented as a rectangle with its name in the top section and its attributes in the bottom, as you see in Figure 1-3.
B9780123756978500017/f01-03-9780123756978.jpg is missing
Figure 1-3
AUML entity
A relation is both column-order independent and row-order independent. This mean that we can view the columns in any order and the rows in any order without losing the meaning of the data. The assumption is, however, that all the data in one row remain in that row.
Domains
Each column in a relation has a domain, an expression of the legal values for that column. In some cases, a domain is very specific. For example, if you are working with a column that stores the sizes of T-shirts, the entire domain might consist of the values S, M, L, XL, and XXL. Domains are more commonly, however, general data types, such as integer or date. 3
3In fact, today's major DBMSs do not provide direct support for true relational domains. Nonetheless you will see that there are SQL constructs that simulate domains.
Once you assign a domain to a column, the DBMS will enforce that domain, rejecting any command that attempts to enter a value into the column that isn't from the domain. This is an example of a constraint on a relation, a rule to which the relation must adhere.
Primary Keys
Each row in a relation must have a unique value that identifies the row. This primary key is made up of the values in one or more columns (the smallest number of columns needed to enforce uniqueness). A table that stores information about an order, for example, would probably use the order number as its primary key.
People are particularly difficult to identify uniquely, so we often assign each person in a table an arbitrary number. If you look back at Figure 1-3, you will see that there is a customer_numb attribute, representing a number that will be simply given to each customer when a row for a new customer is entered into the table. The IE diagramming method places an asterisk in front of the column or columns that make up a primary key, just as is done in Figure 1-3.
Sometimes there is no single column that will uniquely identify each row in a table. As an example, consider the table in Figure 1-4 (dependents), which lists employees' dependent children. We can't use the employee number as the primary key because customer numbers repeat for each child an employee has, and many employees have more than one child. By the same token, the children's names and birthdates aren't unique. The solution is to consider the values in two columns as the primary key. In this case, the employee number and the child's name make the best primary key. Taken as a unit, the two values are unique in every row. A primary key made up of more than one column is known as a concatenated key.
B9780123756978500017/f01-04-9780123756978.jpg is missing
Figure 1-4
A relation with a concatenated primary key
Why are unique primary keys so important? Because they ensure that you can retrieve every piece of data that you put into a database. If primary keys aren't unique, a query will retrieve one or more rows with a value you specify, but you can't be certain which is the exact row you want unless you know something that identifies just that one row. In fact, you should be able to retrieve any single data value knowing three things: the name of the table, the name of the column, and the primary key of the row.
As you will see later in this book, you specify a table's primary key when you define the table to the DBMS. The DBMS will then enforce a constraint that requires unique primary key values.
Note: It is actually possible to create a table that has no primary key, but some DBMSs won't let you put any data in it.
Nulls
Sometimes you don't put data in some columns of some rows because you don't know the appropriate data values. The empty columns don't contain a zero or a blank. Instead, they contain a special indicator known as null, which means “unknown.”
There are two important implications of the presence of nulls in a table. First, we can't allow nulls as all or part of a primary key. If there is only one row with null for a primary key, then the property of unique primary key values is preserved. The minute we introduce a second row with a null primary key, however, the primary keys are no longer unique. A DBMS will therefore ensure that all primary keys have values, a constraint known as entity integrity.
Secondly, nulls can affect the result of queries. Assume, for example, that you want to retrieve the names of all employees who have a salary of more than $100,000. For all employees that have a value in the salary column, the answer to “Is the salary more than $100,000” will be either “yes” or “no.” But if the salary column contains null, the DBMS doesn't know the answer to the question; the result is “maybe.”
We say that a DBMS operates using three-valued logic: yes, no, or maybe. The question that remains is what a DBMS should do when the answer to the question it is asking is “may-be.” Should it retrieve rows with null or leave them out? The relational data model doesn't specify exactly what a DBMS should do, but does require the DBMS to act consistently— either always retrieve rows with nulls or always leave them out—and that the user be aware of what is happening. We'll deal with effect of nulls at various places throughout this book.
Base versus Virtual Tables
There are two primary types of tables with which you will be working when you use SQL. The tables that contain data that are stored in the database are known as base tables. However, the DBMS also uses several types of temporary tables that only exist in main memory. These are virtual tables and by definition they are not stored in the database. Most modern DBMS use several types of virtual tables, including views, temporary tables, and query result tables. If you want to keep the data in a virtual table, then those data must be inserted into a base table.
Representing Relationships
Along with data describing entities, a database must somehow represent relationships between entities. Prior to the relational data model, databases used data structures embedded in the data to show relationships. However, the relational data model relies on it data to show relationships.
Types of Relationships
There are three types of relationships between entities that we encounter in our database environments: one-to-one, one-to-many, and many-to-many.
One-to-One Relationships
A one-to-one relationship exists between two entities when an occurrence of entity A is related to zero or one occurrences of entity B and an occurrence of entity B is related to zero or one occurrences of entity A. Although the specific occurrences involved in the relationship may change over time, there is never more than one related occurrence at any given time. For example, a car and its engine have unique serial numbers. At any one time, an engine is installed in only one car; at the same time, a car has only one engine. The engine may be in no car or it can be moved from one car to another, but it can't be in more than one place at a time. By the same token, a car can have no engine or one engine. The specific engine may change over time but there is never more than one. 4
4Yes, there is at least one exception to the statement that a car has only one engine: hybrids have a gasoline engine and an electric engine. There are exceptions to just about every scenario in this book, so please take them in the spirit in which they were intended: as examples.
We include a relationship in an ERD by drawing a line between the rectangles for two related entities. The line ends identify the type of the relationship. In Figure 1-5 you can see the way in which we would diagram the one-to-one relationship between a car and its engine. The |0 at the end of the line means “zero or one.”
B9780123756978500017/f01-05-9780123756978.jpg is missing
Figure 1-5
A one-to-one relationship
If the relationship is required (mandatory), then the |0 at the end of the line changes to || (one and only one). We use mandatory relationships when we don't want an occurrence of an entity to be store in the database unless it is related to an occurrence of the entity at the other end of the relationship. For example, if we didn't want an engine in the database unless that engine was in a car, the end of the line next to the car entity would be ||.
One-to-many Relationships
True one-to-one relationships are very uncommon, but database environments are full of one-to-many relationships. When a one-to-many relationship exists between two entities, one occurrence of entity A is related to zero, one, or more occurrences of entity B; each occurrence of entity B is related to at most one occurrence of entity A. If, for example, we add car owners to our car database, then there will be a one-to-many relationship between an owner and a car. At any time, a person can own zero, one, or more cars and a car belongs to zero or one owners.
In an ERD, the line between the related entities has |0 or || at one end, representing the zero, one, or more end of the relationship (or one and only one in the case of a mandatory relatioship). The end of the line at the “many” side of the relationship is marked with >0 or >|, representing zero, one, or more (or in the case of a mandatory relationship, one or more). In Figure 1-6, the owner entity is at the “one” end of the relationship and the car entity is at the “many” end.
B9780123756978500017/f01-06-9780123756978.jpg is missing
Figure 1-6
Adding a one-to-many relationship
Many-to-many Relationships
The third type of relationship between entities, a many-to-many relationship, is also very common. When two entities are related in that way, one occurrence of entity A can be related to many occurrences of entity B (zero, one, or more) and one occurrence of entity B can be related to many occurrences of entity A. To demonstrate, let's add an entity for a Web site to the car database, indicating which cars are advertised on which Web sites. A car can be advertised on many Web sites and a site can advertise many cars.
The many-to-many relationship has been diagrammed in Figure 1-7. Notice that each end of the line connecting the Web site and Car entities has the “many” symbol, >0.
B9780123756978500017/f01-07-9780123756978.jpg is missing
Figure 1-7
Adding a many-to-many relationship
While many-to-many relationships are common, they are also a major problem: The relational data model cannot represent them directly, which means that they must be removed from the design and replaced with one-to-many relationships. In Figure 1-8 we have introduced an entity called a Listing. It represents one car being listed on one Web site.
B9780123756978500017/f01-08-9780123756978.jpg is missing
Figure 1-8
Removing many-to-many relationships
The listing entity is what we call a composite entity. It's purpose is to represent the relationship between two other entities. Notice in Figure 1-8 that its primary key is the concatenation of the primary key's of its parent entities (car and Web site).
Foreign Keys and Referential Integrity
If you look back at Figure 1-8, you'll notice that some attributes appear in more than one entity. For example, you can see that the engine entity contains the VIN of the car into which it is inserted. This is how a relational database shows data relationships. When VIN in the engine entity has a value, it represents the relationship with a specific occurrence of car. Any attribute in an entity that is the same as the entire primary key of another entity is known as a foreign key. Table 1-1 lists all the foreign keys in the car database we have been developing.
Table 1-1 Foreign keys in the database design in Figure 1-8
Table containing the foreign keyForeign key attributesTable referenced by foreign key
EngineVINCar
Carengine_serial_numbEngine
owner_numbOwner
ListingURLWeb site
VINCar
A foreign key can be null. For example, if an engine isn't installed in a car, then the VIN attribute in the Engine entity will be null. However, foreign keys that are part of a primary key, such as the URL and VIN attributes in the listing entity, must have values to satisfy entity integrity.
When foreign keys are non-null, a matching primary key value must exist in the table referenced by the foreign key. When a car has an owner, for example, a row with the matching owner_numb must exist in the Owner table. Otherwise, it will be impossible to find information about that owner. This property is known as referential integrity: Every non-null foreign key value must reference an existing primary key value. As you will see throughout this book, much of what you do with SQL involves retrieving matching data using primary key-foreign key relationships.
Foreign keys are not limited to single columns; they can be concatenated, just like primary keys. As an example, consider a part of the database design for a very small accounting firm in Figure 1-9. Because the firm is so small, the database designer decides that employee numbers aren't necessary and instead uses the accountants' first and last names as the primary key of the accountant table. The project table, used to gather data about one accountant preparing one year's tax returns for one customer, uses the tax year and the customer number as its primary key. However, it has three foreign keys. (We'll get to those in a moment.) The form table that stores data about the forms that are part of a specific tax return uses the concatenation of the form's ID and the primary key of the project table for its primary key.
B9780123756978500017/f01-09-9780123756978.jpg is missing
Figure 1-9
A part of a database design with concatenated foreign keys
A foreign key is the same as the complete primary key of another table. Therefore, the acct_first_name attribute by itself in the project table is not a foreign key; neither is the acc_ last_name attribute. If you concatenate them, however, then they are the same as the primary key of the accountant table and, in fact, this is the unit with which referential integrity should be enforced.
Assume that “Jane Johnson” is working on customer 10100's 2014 tax return. It's not enough to ensure that “Jane” appears somewhere in the first name column in the accountant table and “Johnson” appears anywhere in the last name column in the accountant table. There could be many people named “Jane” and many with the last name of “Johnson.” What we need to ensure is that there is one person named “Jane Johnson” in the accountant table, the concatenation of the two attributes that make up the primary key.
The same holds true for the concatenated foreign key in the form table: the tax year and the customer number. A row with a matching pair must exist in the project table before referential integrity is satisfied.
Views
Users don't necessarily work directly with base tables. Instead, they use views, which present a subset of the database. A view can be constructed from one or more tables and/or views, using one or more columns and one or more rows.
Views are stored in the database as SQL query expressions. Each has a name. When someone uses the name of the view, either from the command line or in an application program, the DBMS executes the query and assembles a virtual table in main memory. The user can then see the view's data, query the view, and in some cases, use it for updates.
There are two main reasons for using views. First, they let you store complex queries in the database. The user then doesn't need to type the entire query, but can use the view's name. Second, views provide a security mechanism. Users are prohibited from accessing base tables directly but instead work with views that present the portions of the database to which they should have access.
The Design of the Sample Database
Most of the sample queries throughout this book are taken from a portion of a relational database that supports a rare book dealer. You can find the ER diagram in Figure 1-10. The rare book dealer handles rare fiction editions and some modern fiction. Because many of the books are one-of-a-kind, he tracks each volume individually.
B9780123756978500017/f01-10-9780123756978.jpg is missing
Figure 1-10
The complete ERD for the rare book store database
The portion of the database we will be using contains data on customers and the volumes that they purchase. Notice, however, that it really takes three entities to describe a volume that is sold. The work entity describes a text written by one author with one title. A book is a specific published version of a work; it is identified by an ISBN. A volume is one copy of a book. This is the unit that is being sold.
Notice that many of the text attributes of a work/book/volume are represented by numeric codes that act as foreign keys. For example, a book has a work_id that connects it to the work. It also has a publisher_id that connects to a table that contains the text of publisher names. Why design the database this way? Because it is very easy to make mistakes when typing text; data that are repeated may become inconsistent, resulting in queries that don't retrieve all appropriate rows. Therefore, we store the text just once and relate it to works/books/volumes using integer codes.
The data that we will be using appear in Table 1-2Table 1-3Table 1-4Table 1-5Table 1-6Table 1-7Table 1-8 and Table 1-9. 5 With the exception of work authors and titles, the data are fictional, made up just for use in this book.
5Some column names have been abbreviated so the data will fit on the printed page.
Table 1-2 Publisher
publisher_idpublisher_name
1Wiley
2Simon & Schuster
3Macmillan
4Tor
5DAW
Table 1-3 Author
author_numbauthor_last_first
1Bronte, Charlotte
2Doyle, Sir Arthur Conan
3Twain, Mark
4Stevenson, Robert Louis
5Rand, Ayn
6Barrie, James
7Ludlum, Robert
8Barth, John
9Herbert, Frank
10Asimov, Isaac
11Funke, Cornelia
12Stephenson, Neal
Table 1-4 Condition codes
condition_codecondition_description
1New
2Excellent
3Fine
4Good
5Poor
Table 1-5 Work
work_numbauthor_numbtitle
11Jane Eyre
21Villette
32Hound of the Baskervilles
42Lost World, The
52Complete Sherlock Holmes
73Prince and the Pauper
83Tom Sawyer
93Adventures of Huckleberry Finn, The
63Connecticut Yankee in King Arthur's Court, A
135Fountainhead, The
145Atlas Shrugged
156Peter Pan
107Bourne Identity, The
117Matarese Circle, The
127Bourne Supremacy, The
164Kidnapped
174Treasure Island
188Sot Weed Factor, The
198Lost in the Funhouse
208Giles Goat Boy
219Dune
229Dune Messiah
2310Foundation
2410Last Foundation
2510I, Robot
2611Inkheart
2711Inkdeath
2812Anathem
2912Snow Crash
305Anthem
3112Cryptonomicon
Table 1-6 Books
isbnwork_numbpublisher_ideditionbindingcopyright_year
978-1-11111-111-1112Board1857
978-1-11111-112-1111Board1847
978-1-11111-113-1241Board1842
978-1-11111-114-1341Board1801
978-1-11111-115-13410Leather1925
978-1-11111-116-1431Board1805
978-1-11111-117-1551Board1808
978-1-11111-118-15219Leather1956
978-1-11111-120-1845Board1906
978-1-11111-119-1623Board1956
978-1-11111-121-18112Leather1982
978-1-11111-122-19112Leather1982
978-1-11111-123-11121Board1998
978-1-11111-124-11221Board1989
978-1-11111-125-11323Board1965
978-1-11111-126-11329Leather2001
978-1-11111-127-11421Board1960
978-1-11111-128-116212Board1960
978-1-11111-129-116214Leather2002
978-1-11111-130-11736Leather1905
978-1-11111-131-11846Board1957
978-1-11111-132-11941Board1962
978-1-11111-133-12041Board1964
978-1-11111-134-12151Board1964
978-1-11111-135-12351Board1962
978-1-11111-136-12354Leather2001
978-1-11111-137-12454Leather2001
978-1-11111-138-12354Leather2001
978-1-11111-139-12554Leather2001
978-1-11111-140-12651Board2001
978-1-11111-141-12751Board2005
978-1-11111-142-12851Board2008
978-1-11111-143-12951Board1992
978-1-11111-144-13011Board1952
978-1-11111-145-13051Board2001
978-1-11111-146-13151Board1999
Table 1-7 Volume
inventory_idisbncondition_codedate_acquiredasking_priceselling_pricesale_id
1978-1-11111-111-1312-JUN-12 00:00:00175.00175.001
2978-1-11111-131-1423-JAN-12 00:00:0050.0050.001
7978-1-11111-137-1220-JUN-12 00:00:0080.00
3978-1-11111-133-1205-APR-11 00:00:00300.00285.001
4978-1-11111-142-1105-APR-11 00:00:0025.9525.952
5978-1-11111-146-1105-APR-11 00:00:0022.9522.952
6978-1-11111-144-1215-MAY-12 00:00:0080.0076.102
8978-1-11111-137-1320-JUN-12 00:00:0050.00
9978-1-11111-136-1120-DEC-11 00:00:0075.00
10978-1-11111-136-1215-DEC-11 00:00:0050.00
11978-1-11111-143-1105-APR-12 00:00:0025.0025.003
12978-1-11111-132-1112-JUN-12 00:00:0015.0015.003
13978-1-11111-133-1320-APR-12 00:00:0018.0018.003
15978-1-11111-121-1220-APR-12 00:00:00110.00110.005
14978-1-11111-121-1220-APR-12 00:00:00110.00110.004
16978-1-11111-121-1220-APR-12 00:00:00110.00
17978-1-11111-124-1212-JAN-13 00:00:0075.00
18978-1-11111-146-1111-MAY-12 00:00:0030.0030.006
19978-1-11111-122-1206-MAY-12 00:00:0075.0075.006
20978-1-11111-130-1220-APR-12 00:00:00150.00120.006
21978-1-11111-126-1220-APR-12 00:00:0010.00110.006
22978-1-11111-139-1216-MAY-12 00:00:00200.00170.006
23978-1-11111-125-1216-MAY-12 00:00:0045.0045.007
24978-1-11111-131-1320-APR-12 00:00:0035.0035.007
25978-1-11111-126-1216-NOV-12 00:00:0075.0075.008
26978-1-11111-133-1316-NOV-12 00:00:0035.0055.008
27978-1-11111-141-1106-NOV-12 00:00:0024.95
28978-1-11111-141-1106-NOV-12 00:00:0024.95
29978-1-11111-141-1106-NOV-12 00:00:0024.95
30978-1-11111-145-1106-NOV-12 00:00:0027.95
31978-1-11111-145-1106-NOV-12 00:00:0027.95
32978-1-11111-145-1106-NOV-12 00:00:0027.95
33978-1-11111-139-1206-OCT-12 00:00:0075.0050.009
34978-1-11111-133-1116-NOV-12 00:00:00125.00125.0010
35978-1-11111-126-1106-OCT-12 00:00:0075.0075.0011
36978-1-11111-130-1306-DEC-11 00:00:0050.0050.00
37978-1-11111-136-1306-DEC-11 00:00:0075.0075.0011
38978-1-11111-130-1206-APR-12 00:00:00200.00150.0012
39978-1-11111-132-1306-APR-12 00:00:0075.0075.0012
40978-1-11111-129-1106-APR-12 00:00:0025.9525.9513
41978-1-11111-141-1116-MAY-12 00:00:0040.0040.0014
42978-1-11111-141-1116-MAY-12 00:00:0040.0040.0014
43978-1-11111-132-1112-NOV-12 00:00:0017.95
44978-1-11111-138-1112-NOV-12 00:00:0075.95
45978-1-11111-138-1112-NOV-12 00:00:0075.95
46978-1-11111-131-1312-NOV-12 00:00:0015.95
47978-1-11111-140-1312-NOV-12 00:00:0025.95
48978-1-11111-123-1216-AUG-12 00:00:0024.95
49978-1-11111-127-1216-AUG-12 00:00:0027.95
50978-1-11111-127-1206-JAN-13 00:00:0050.0050.0015
51978-1-11111-141-1206-JAN-13 00:00:0050.0050.0015
52978-1-11111-141-1206-JAN-13 00:00:0050.0050.0016
53978-1-11111-123-1206-JAN-13 00:00:0040.0040.0016
54978-1-11111-127-1206-JAN-13 00:00:0040.0040.0016
55978-1-11111-133-1206-FEB-13 00:00:0060.0060.0017
56978-1-11111-127-1216-FEB-12 00:00:0040.0040.0017
57978-1-11111-135-1216-FEB-12 00:00:0040.0040.0018
59978-1-11111-127-1225-FEB-13 00:00:0035.0035.0018
58978-1-11111-131-1216-FEB-13 00:00:0025.0025.0018
60978-1-11111-128-1216-DEC-12 00:00:0050.0045.0019
61978-1-11111-136-1322-OCT-12 00:00:0050.0050.0019
62978-1-11111-115-1222-OCT-12 00:00:0075.0075.0020
63978-1-11111-130-1216-JUL-12 00:00:00500.00
64978-1-11111-136-1206-MAR-12 00:00:00125.00
65978-1-11111-136-1206-MAR-12 00:00:00125.00
66978-1-11111-137-1206-MAR-12 00:00:00125.00
67978-1-11111-137-1206-MAR-12 00:00:00125.00
68978-1-11111-138-1206-MAR-12 00:00:00125.00
69978-1-11111-138-1206-MAR-12 00:00:00125.00
70978-1-11111-139-1206-MAR-12 00:00:00125.00
71978-1-11111-139-1206-MAR-12 00:00:00125.00
Table 1-8 Customers
cust # numbfirst_namelast_namestreetcitystate prov.zip_postcontact_phone
1JaniceJones125 Center RoadAnytownNY11111518-555-1111
2JonJones25 Elm RoadNext TownNJ18888209-555-2222
3JohnDoe821 Elm StreetNext TownNJ18888209-555-3333
4JaneDoe852 Main StreetAnytownNY11111518-555-4444
5JaneSmith1919 Main StreetNew VillageNY13333518-555-5555
6JaniceSmith800 Center RoadAnytownNY11111518-555-6666
7HelenBrown25 Front StreetAnytownNY11111518-555-7777
8HelenJerry16 Main StreetNewtownNJ18886518-555-8888
9MaryCollins301 Pine Road, Apt. 12NewtownNJ18886518-555-9999
10PeterCollins18 Main StreetNewtownNJ18886518-555-1010
11EdnaHayes209 Circle RoadAnytownNY11111518-555-1110
12FranklinHayes615 Circle RoadAnytownNY11111518-555-1212
13PeterJohnson22 Rose CourtNext TownNJ18888209-555-1212
14PeterJohnson881 Front StreetNext TownNJ18888209-555-1414
15JohnSmith881 Manor LaneNext TownNJ18888209-555-1515
Table 1-9 Sale
sale_idcustomer_numbsale_datesale_total_amtcredit_card_numbexp_monthexp_year
3115-JUN-13 00:00:0058.001234 5678 9101 11211018
4430-JUN-13 00:00:00110.001234 5678 9101 5555717
5630-JUN-13 00:00:00110.001234 5678 9101 66661217
61205-JUL-13 00:00:00505.001234 5678 9101 7777716
7805-JUL-13 00:00:0080.001234 5678 9101 8888816
8507-JUL-13 00:00:0090.001234 5678 9101 9999915
9807-JUL-13 00:00:0050.001234 5678 9101 8888816
101110-JUL-13 00:00:00125.001234 5678 9101 10101116
11910-JUL-13 00:00:00200.001234 5678 9101 09091115
121010-JUL-13 00:00:00200.001234 5678 9101 01011015
13210-JUL-13 00:00:0025.951234 5678 9101 2222215
14610-JUL-13 00:00:0080.001234 5678 9101 66661217
151112-JUL-13 00:00:0075.001234 5678 9101 12311117
16225-JUL-13 00:00:00130.001234 5678 9101 2222215
17125-JUL-13 00:00:00100.001234 5678 9101 11211018
18522-AUG-13 00:00:00100.001234 5678 9101 9999915
2105-JUN-13 00:00:00125.001234 5678 9101 11211018
1129-MAY-13 00:00:00510.001234 5678 9101 11211018
19601-SEP-13 00:00:0095.001234 5678 9101 7777716
20201-SEP-13 00:00:0075.001234 5678 9101 2222215
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.247.68