MUSICIAN_ID INTEGER FOREIGN KEY REFERENCES MUSICIAN WITH NULL, DATE DATE NOT NULL, TEXT MEMO NOT NULL ); The Microsoft Access MEMO datatype is used to represent very large strings. Exercise 2 solution CREATE TABLE INSTRUMENT ( INSTRUMENT_ID INTEGER PRIMARY KEY NOT NULL, SECTION_ID INTEGER FOREIGN KEY REFERENCES INSTRUMENT WITH NULL, INSTRUMENT CHAR VARYING(32) NOT NULL ); CREATE TABLE MUSICIAN ( MUSICIAN_ID INTEGER PRIMARY KEY NOT NULL, MUSICIAN CHAR VARYING(32) NOT NULL, PHONE CHAR VARYING(32) NULL, EMAIL CHAR VARYING(32) NULL ); CREATE TABLE GENRE ( GENRE_ID INTEGER PRIMARY KEY NOT NULL, PARENT_ID INTEGER FOREIGN KEY REFERENCES GENRE WITH NULL, GENRE CHAR VARYING(32) NOT NULL ); CREATE TABLE BAND ( BAND_ID INTEGER PRIMARY KEY NOT NULL, BAND CHAR VARYING(32) NOT NULL, FOUNDING_DATE DATE NOT NULL ); CREATE TABLE ADVERTISEMENT ( ADVERTISEMENT_ID INTEGER PRIMARY KEY NOT NULL, DATE DATE NOT NULL, TEXT MEMO NOT NULL ); CREATE TABLE DISCOGRAPHY ( DISCOGRAPHY_ID INTEGER PRIMARY KEY NOT NULL, CD_NAME CHAR VARYING(32) NOT NULL, RELEASE_DATE DATE NULL, PRICE MONEY NULL ); CREATE TABLE MERCHANDISE ( 433 Exercise Answers 22_574906 appa.qxd 10/28/05 11:38 PM Page 433 MERCHANDISE_ID INTEGER PRIMARY KEY NOT NULL, TYPE CHAR VARYING(32) NOT NULL, PRICE MONEY NOT NULL ); CREATE TABLE SHOW_VENUE ( SHOW_ID INTEGER PRIMARY KEY NOT NULL, LOCATION CHAR VARYING(32) NOT NULL, ADDRESS_LINE_1 CHAR VARYING(32) NOT NULL, ADDRESS_LINE_2 CHAR VARYING(32) NULL, TOWN CHAR VARYING(32) NOT NULL, ZIP NUMBER(5) NULL, POSTAL_CODE CHAR VARYING(32) NULL, COUNTRY CHAR VARYING(32) NULL, DIRECTIONS MEMO NULL, PHONE CHAR VARYING(32) NULL SHOW_DATE DATE NOT NULL, SHOW_TIME CHAR VARYING(16) NOT NULL ); VENUE is changed to LOCATION CREATE TABLE FACT ( FACT_ID INTEGER NOT NULL, SHOW_ID INTEGER FOREIGN KEY REFERENCES SHOW WITH NULL, MUSICIAN_ID INTEGER FOREIGN KEY REFERENCES MUSICIAN WITH NULL, BAND_ID INTEGER FOREIGN KEY REFERENCES BAND WITH NULL, ADVERTISEMENT_ID INTEGER FOREIGN KEY REFERENCES ADVERTISEMENT WITH NULL, DISCOGRAPHY_ID INTEGER FOREIGN KEY REFERENCES DISCOGRAPHY WITH NULL, MERCHANDISE_ID INTEGER FOREIGN KEY REFERENCES MERCHANDISE WITH NULL, GENRE_ID INTEGER FOREIGN KEY REFERENCES GENRE WITH NULL, INSTRUMENT_ID INTEGER FOREIGN KEY REFERENCES INSTRUMENT WITH NULL, CD_SALE_AMOUNT MONEY NULL, MERCHANDISE_SALE_AMOUNT MONEY NULL, ADVERTISING_COST_AMOUNT MONEY NULL, SHOW_TICKET_SALES_AMOUNT_MONEY NULL ); 434 Appendix A 22_574906 appa.qxd 10/28/05 11:38 PM Page 434 B Sample Databases This appendix contains what should the most sensible versions of some of the more complete ERD database model diagrams, as presented in this book. This appendix is intended merely as a refer- ence of database model ERDs. Following is a summary of the ERDs included in this appendix. ❑ Figure B-1 shows the book publication OLTP ERD. ❑ Figure B-2 shows the book publication reviews data warehouse ERD. ❑ Figure B-3 shows the book publication sales data warehouse ERD. ❑ Figure B-4 shows the musicians, bands, and advertisements OLTP ERD. ❑ Figure B-5 shows the musicians, bands, and advertisements data warehouse ERD. ❑ Figure B-6 shows the online auction house OLTP ERD. ❑ Figure B-7 shows the online auction house data warehouse ERD. 23_574906 appb.qxd 10/28/05 11:43 PM Page 435 Figure B-1: Book publication OLTP ERD. Customer customer_id customer address phone email credit_card_type credit_card# credit_card_expiry Publisher publisher_id name Subject subject_id parent_id (FK) name Review review_id publication_id (FK) review_date text Sale sale_id ISBN (FK) shipper_id (FK) customer_id (FK) sale_price sale_date Publication publication_id subject_id (FK) author_id (FK) title Shipper shipper_id shipper address phone email Edition ISBN publisher_id (FK) publication_id (FK) print_date pages list_price format Author author_id name CoAuthor cuoauthor_id (FK) publication_id (FK) Rank ISBN (FK) rank ingram_units 436 Appendix B 23_574906 appb.qxd 10/28/05 11:43 PM Page 436 Figure B-2: Book publication reviews data warehouse ERD. Review review_id customer_id (FK) publication_id (FK) author_id (FK) publisher_id (FK) review_date text publisher Publisher publisher_id Author author_id author Publication publication_id title Customer customer_id customer address phone email credit_card_type credit_card# credit_card_expiry 437 Sample Databases 23_574906 appb.qxd 10/28/05 11:43 PM Page 437 Figure B-3: Book publication sales data warehouse ERD. Sale sale_id ISBN (FK) author_id (FK) shipper_id (FK) customer_id (FK) subject_id (FK) sale_price sale_date author Author author_id Book ISBN publisher title edition# print_date pages list_price format rank ingram_units Customer customer_id customer address phone email credit_card_type credit_card# credit_card_expiry Subject subject_id category subject Shipper shipper_id shipper address phone email 438 Appendix B 23_574906 appb.qxd 10/28/05 11:43 PM Page 438 Figure B-4: Musicians, bands, and advertisements OLTP ERD. Musician musician_id instrument_id (FK) band_id (FK) musician phone email skills Advertisement advertisement_id band_id (FK) musician_id (FK) date text Band band_id genre_id (FK) band founding_date Venue venue_id location address_line_1 address_line_2 town zip postal_code country directions phone Merchandise merchandise_id band_id (FK) type price Show show_id band_id (FK) venue_id (FK) date time Genre genre_id parent_id (FK) genre Instrument instrument_id section_id (FK) instrument Discography discography_id band_id (FK) cd_name release_date price 439 Sample Databases 23_574906 appb.qxd 10/28/05 11:43 PM Page 439 Figure B-5: Musicians, bands, and advertisements data warehouse ERD. Fact fact_id location_id (FK) time_id (FK) show_id (FK) musician_id (FK) band_id (FK) advertisement_id (FK) discography_id (FK) merchandise_id (FK) genre_id (FK) instrument_id (FK) cd_sale_amount merchandise_sale_amount advertising_cost_amount show_ticket_sales_amount Genre genre_id parent_id (FK) genre Band band_id band founding_date Advertisement advertisement_id date text Discography discography_id cd_name release_date price Show_Venue show_id venue address_line_1 address_line_2 town zip postal_code country show_date show_time Merchandise merchandise_id type price Time time_id year# quarter# month# Location location_id region country state city Instrument instrument_id section_id (FK) instrument Musician musician_id musician phone email 440 Appendix B 23_574906 appb.qxd 10/28/05 11:43 PM Page 440 Figure B-6: Online auction house OLTP ERD. Listing listing# buyer_id (FK) seller_id (FK) category_id (FK) ticker (FK) description image start_date listing_days starting_price bid_increment reserve_price buy_now_price number_of_bids winning_price current_price History History_id seller_id (FK) buyer_id (FK) comment_date feedback_positive feedback_neutral feedback_negative Seller seller_id seller company company_url popularity_rating join_date address_line_1 address_line_2 town zip postal_code country return_policy international_shipping payment_method_personal_check payment_method_cashiers_check payment_method_paypal payment_method_western_union payment_ method_USPS_postal_order payment_method_international_postal_order payment_method_wire_transfer payment_method_cash payment_method_visa payment_method_mastercard payment_method_american_express Buyer buyer_id buyer popularity_rating join_date address_line_1 address_line_2 town zip postal_code country Currency ticker currency exchange_rate decimals Category_Hierarchy category_id parent_id (FK) category Bid listing# (FK) buyer_id (FK) bid_price proxy_bid bid_date 441 Sample Databases 23_574906 appb.qxd 10/28/05 11:43 PM Page 441 Figure B-7: Online auction house data warehouse ERD. Bidder bidder_id bidder popularity_rating feedback_positives feedback_neutrals feedback_negative Category_Hierarchy category_id parent_id (FK) category Seller seller_id seller company company_url popularity_rating feedback_positives feedback_neutrals feedback_negatives Location location_id region country state city currency_ticker currency exchange_rate decimals Time time_id year quarter month Listing_Bids bid_id buyer_id (FK) bidder_id (FK) seller_id (FK) time_id (FK) location_id (FK) category_id (FK) listing# listing_start_date listing_days listing_starting_price listing_bid_increment listing_reserve_price listing_buy_now_price listing_number_of_bids listing_winning_price bid_price 442 Appendix B 23_574906 appb.qxd 10/28/05 11:43 PM Page 442 [...]... business rules data warehouse database model, 370–373, 377–379 described, 364 OLTP database model, 364–370, 374–377 data warehouse database sample, 349–352 described, 37–38, 40–42, 409 explicitly declared, 357–358 indexing too many, 65 OLTP database sample, 346–348 restricting values constraints, 47–48 datatype, 4 structure data warehouse database model, 323–329 OLTP database model, 320–323 validation,... partitioning and parallel processing, 385 referential integrity, 279–282 refining, 308–316 database defined, 407 evolution, 3, 407 SQL languages for different brands, 125–126 structure change, 127 database block, 407 database concept, 4–5 database event, 27, 418 database model application, 3, 5–6 decision support databases, 15–16, 407 defined, 3, 407 design importance, 16–17 methods, 20–21 objectives,... evolution of, 6–7 file systems, 7 functional categories, 14 hierarchical, 8 hybrid databases, 16 network, 8–9 object database model, 12–13 object-relational database model, 14 relational benefits, 9 diagram illustrating, 9–10 history, 11–12 RDBMS, 11 transactional databases, 15 database procedures See stored procedures database rule, 27, 418 datatype Access, 331 ANSI, 330 complex binary objects, 46–47... stored procedure, 360–362 described, 354–355, 405 encoding data warehouse database model, 374 OLTP database model, 373–374 field level data warehouse database model, 370–373, 377–379 described, 364 OLTP database model, 364–370, 374–377 fields, explicitly declared, 357–358 normalization, normal forms, and relations, 355–356 OLTP database model analysis described, 232–233 one-to-many, 233–234 tables, online... Institute) datatypes, 330 defined, 404 application caching, 211–212 complexity handled by object database model, 13 database model, 5–6 defined, 3, 404 dependence, minimizing to accommodate changes, 19 446 as latest evolution of database modeling, 3 OLTP database model changes, 323 rewriting, 260 standard database model, 225 approval, design issues, 260–261 arithmetical precedence, 133 ascending order,... conceptual design, 20 concurrency/concurrent client-server database, 195 data warehouse database, 196 described, 406 hardware, 173 OLTP database, 194, 198, 344 querying all fields, 200 configuration, 383, 406 constraints business rules, 26 described, 406 referential integrity, ensuring, 64 validation, 47–48 construction step, 220, 406 copying database replication, 399–400 fields between tables, 163 correlation... fields that may become multiples (BIGSTRING), 268 formatting, 41 indexing, 208 OLTP database model field, specifying, 333–335 sample, 346–348 samples defining data warehouse database model, 336–338 OLTP database model, 332–336 simple described, 329–330 numbers, 44–46 strings, 42–43 specialized, 47, 331–332 dataware database defined, 6 performance tuning design phase, 197–198 factors, 196–197 dates... cascading records to, 64 foreign keys, 60, 64 hierarchical database model, 8 many-to-many relationships, network database model, 8–9 with optional parent tables, 273 class defined, 165, 405 methods, encapsulating processing, 354 object versus, 165 relationships between, 166 classified ads for musicians See online musicians sample client-server database model described, 15, 405–406 performance tuning,... company objectives, 226–228 standard database model, 225 business processes data warehouse modeling, 183 described, 405 explaining, 219–220 operations, 222 requirements analysis, 221 business rules analysis data warehouse model, 248–252 described, 222 OLTP database model, 232–234 447 Index business rules business rules (continued) business rules (continued) code, storing in database described, 358–360 event... 115–116 normal form, 81 transitive dependence, 77 dependent entity or table, 57, 58 descending order, indexing, 68, 404, 408 design database model importance, 16–17 methods, 20–21 objectives, defining, 17–19 dataware database model performance tuning, 197–198 defined, 408 OLTP database model sample, 302–308 steps, 220 detail record, adding without master record, 74–75, 411 determinant BCNF normalization . Page 450 database defined, 407 evolution, 3, 407 SQL languages for different brands, 125–126 structure change, 127 database block, 407 database concept, 4–5 database event, 27, 418 database model application,. 354–355, 405 encoding data warehouse database model, 374 OLTP database model, 373–374 field level data warehouse database model, 370–373, 377–379 described, 364 OLTP database model, 364–370, 374–377 fields,. handled by object database model, 13 database model, 5–6 defined, 3, 404 dependence, minimizing to accommodate changes, 19 as latest evolution of database modeling, 3 OLTP database model changes,