Populating the View Ridge Database Tables
Populating the View Ridge Database Tables
Now that we know how to use the SQL INSERT statement to add rows of data to a table, we can put data into the View Ridge database. Sample data for the View Ridge database is shown in Figure 7-16.
However, we need to be careful about exactly how we enter this data into the View Ridge database. Notice that in the SQL CREATE TABLE statements in Figure 7-14 that CustomerID, ArtistID, WorkID, and TransactionID are all surrogate keys with values automatically inserted by the DBMS. This will produce sequential numbers. For example, if we insert the ARTIST table data shown in Figure 7-16(b) using the automatic ArtistID numbering from IDENTITY(1, 1), the ArtistID numbers for the nine artists will be (1, 2, 3, 4, 5, 6, 7, 8, 9). But in Figure 7-12(b), the ArtistID numbers are (1, 2, 3, 4, 5, 11, 17, 18, 19).
This happens because the View Ridge data shown in Figure 7-16 is sample data, not the complete data for the database. Therefore, the primary key numbers for CustomerID, ArtistID, WorkID, and TransactionID in the data set are not sequential.
Chapter 7 SQL for Database Construction and Application Processing
CustomerID LastName
FirstName Street
City
State ZipPostalCode
813 Tumbleweed Lane Durango
88 1st Avenue
10899 88th Ave
Bainbridge Island WA
Frederickson Mary Beth
25 South Lafayette
Denver
CO
BC V6Z 1W2 1037
105 Locust Ave
55 Bodega Ave
Bodega Bay
117 C Street
87 Highland Drive
CustomerID LastName
FirstName Country AreaCode PhoneNumber Email
[email protected] 1001
[email protected] 1015
[email protected] 1033
[email protected] 1034
[email protected] 1036
Frederickson Mary Beth USA
513-8822
[email protected] 1037
[email protected] 1040
[email protected] 1041
(a) CUSTOMER Table Data
(continued)
Figure 7-16
Sample Data for the View Ridge Database
This, of course, raises the question of how to override DBMS mechanisms that provide automatic surrogate key numbering. The answer to this question varies among DBMS products (as does the method for generating the surrogate values). A discussion of this topic and the complete set of SQL INSERT statements needed to enter the data for the DBMS products discussed in this text are in Chapters 10 (SQL Server 2008 R2), 10A (Oracle Database 11g), and 10B (MySQL 5.5). At this point, we recommend that you read the appro- priate section for the DBMS product you are using and populate the View Ridge database in your DBMS.
Part 3 Database Implementation
ArtistID LastName
John Singer
United States
United States
United States
Morris
United States
(b) ARTIST Table Data
Figure 7-16
19 1051 Continued
(c) CUSTOMER_ARTIST_INT Table Data
WorkID Title
500 Memories IV
Casein rice paper collage
31 x 24.8 in.
Unique
Surf and Bird
High Quality Limited Print Northwest School Expressionist style
The Tilled Field
High Quality Limited Print Early Surrealist style
La Lecon de Ski
High Quality Limited Print Surrealist style
On White II
High Quality Limited Print Bauhaus style of Kandinsky
Woman with a Hat
High Quality Limited Print
A very colorful Impressionist piece
The Woven World
Color lithograph
Night Bird
Watercolor on Paper
50 x 72.5 cm.—Signed
Unique
Der Blaue Reiter
High Quality Limited Print “The Blue Rider”—Early Pointilism influence
Angelus Novus
High Quality Limited Print Bauhaus style of Klee
The Dance
High Quality Limited Print An Impressionist masterpiece
I and the Village
High Quality Limited Print Shows Belarusian folk-life themes and symbology
Claude Monet Painting High Quality Limited Print Shows French Impressionist influence of Monet
Watercolor and ink
33.3 x 16.1 cm.—Signed
Unique
The Fiddler
High Quality Limited Print Shows Belarusian folk-life themes and symbology
Spanish Dancer
High Quality Limited Print American realist style—From work in Spain
Farmer’s Market #2
High Quality Limited Print Northwest School Abstract Expressionist style
(d) WORK Table Data
(continued)
Figure 7-16
Continued
WorkID Title
Medium
Description
Copy ArtistID
565 Farmer’s Market #2
High Quality Limited Print Northwest School Abstract Expressionist style
Into Time
High Quality Limited Print Northwest School Abstract Expressionist style
Unique 17 571
Untitled Number 1
Monotype with tempera
4.3 x 6.1 in.—Signed
Unique 18 578
Yellow covers blue
Oil and collage
71 x 78 in.—Signed
Mid Century Hibernation High Quality Limited Print Northwest School Expressionist style 362/500 19 580
Unique 17 581
Forms in Progress I
Color aquatint
19.3 x 24.4 in.—Signed
Unique 17 585
Forms in Progress II
Color aquatint
19.3 x 24.4 in.—Signed
The Fiddler
High Quality Limited Print Shows Belarusian folk-life themes and symbology
Spanish Dancer
High Quality Limited Print American Realist style—From work in Spain
Broadway Boggie
High Quality Limited Print Northwest School Abstract Expressionist style
Universal Field
High Quality Limited Print Northwest School Abstract Expressionist style
Color Floating in Time
High Quality Limited Print Northwest School Abstract Expressionist style
Unique 17 593
Blue Interior
Tempera on card
43.9 x 28 in.
Unique 19 594
Surf and Bird
Gouache
26.5 x 29.75 in.—Signed
Surf and Bird
High Quality Limited Print Northwest School Expressionist style
Surf and Bird
High Quality Limited Print Northwest School Expressionist style
Surf and Bird
High Quality Limited Print Northwest School Expressionist style
(d) WORK Table Data
Figure 7-16
Continued
Chapter 7 SQL for Database Construction and Application Processing
TransactionID DateAcquired AcquisitionPrice AskingPrice DateSoldID SalesPrice CustomerID WorkID
(e) TRANS Table Data
Figure 7-16
Continued
Part 3 Database Implementation