Beginning Database Design- P14 pot

20 231 0
Beginning Database Design- P14 pot

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

The business rules of a company, when applied to a database model, become that database model. The business rules are the tables, relationships between those tables, and even the constraint rules (in addition to referential integrity constraints) in a database. In fact, the application of normalization to a set of initial company data tables is a more and more complex application of business rules to that company data environment. Normalization is the application of business rules. Figure 9-7: Iterative steps in the analysis methodology. Figure 9-8 shows some very simple example business rules. In Figure 9-8, there are many categories of instruments listed for auction. Each separate category of instruments (such as brass instruments, or the brass section) has numerous instruments (such as a trumpet, trombone, or sousaphone). Figure 9-8: A one-to-many relationship is a business rule. Brass brass_id category_id (FK) brass manufacturer in_stock Stringed Instrument stringed_id category_id (FK) stringed_instrument manufacturer in_stock number_of_strings Woodwind woodwind_id Percussion percussion_id category_id (FK) percussion manufacturer in_stock free_snare_drum Category category_id category category_id (FK) woodwind manufacturer in_stock used_or_new Each category has many subcategories, in turn having many individual instruments One-to-many business rule s One-to-many business rule s Company Operations Overall Objectives Business Rules Budgeting Planning and Timeline Other Factors All these steps can be reworked in any order. Obviously rework means rework of all subsequent steps, if there are any dependencies 233 Planning and Preparation Through Analysis 15_574906 ch09.qxd 11/4/05 10:49 AM Page 233 In Figure 9-8, the very act of separating each of multiple instrument sections into separate tables is a very simplistic form of creating business rule representations, using tables and the relationships between them. The ERD in Figure 9-8 is not standard normalization, but is shown to demonstrate clearly how the relationships created between different tables actually create the business rules, or operational functionality of a company. In this case, the company is the online auction company that allows auction listings for sales of musical instruments, for sale at auctions online. Auction House Categories Figure 9-9 shows a data picture of some of the structural table elements shown in Figure 9-8. The Guitar category has two instruments: Acoustic Guitar and Electric Guitar. The Wind category has numerous instruments. Figure 9-9: Some of the data in Figure 9-8. At this stage, you can take the operations of the online auction house, established previously in Figure 9-3 to Figure 9-6, and create ERDs for those structures. As already stated previously in this chapter, business rules are at the heart of the analysis stage, describing what has been analyzed and what must be created to design the database model. The business rules part of the analysis of a database model entails creation of tables, and the basic relationships between those tables. 1 2 3 4 5 6 7 8 Guitar General Percussion Piano String Vocals Wind Orchestra 1 2 3 4 5 6 18 19 20 21 22 23 24 25 26 27 28 1 1 7 7 3 4 5 5 7 7 3 4 3 2 2 7 1 Acoustic Guitar Electric Guitar Brass Woodwind Alto Horn Alto Saxophone Electronic Drums Fiddle Flugelhorn Flute French Horn Keyboards Latin Percussion Lead Guitar Mellophone Piccolo Rhythm Guitar Category Category Instrumen t Instrumen t 234 Chapter 9 15_574906 ch09.qxd 11/4/05 10:49 AM Page 234 The overall aim of analysis is merely to define rather than specify with precision; therefore, analysis does not describe how many fields should be used for an address, for example, or what datatypes those fields should be. Analysis simply determines that an address field actually exists, and obviously which table or tables address information is required within. Starting with the categories static structures in Figure 9-3, the ERD section in Figure 9-10 caters effectively to the category hierarchical structure, and the link to the table containing auction listings. The LISTING table has all the details for the master side of a master — detail table that depicts table design, including a description, listing table number reference ( LISTING#), dates, prices, bids, and winning bidder details. Figure 9-10: An ERD version of the category hierarchical structure of Figure 9-3. As can be seen in Figure 9-10, the process of analysis is beginning to become one of partial definition, without specifics, of course, where individual fields are defined for different attributes of specific operations. Figure 9-11 and Figure 9-12 show some sample data (including surrogate key fields), to be represented by the ERD in Figure 9-10. Listing listing# description image start_date end_date starting_price reserve_price buy_now_price number_of_bids winning_price buyer Category_Primary primary Category_Tertiary tertiary Category_Secondary secondary 235 Planning and Preparation Through Analysis 15_574906 ch09.qxd 11/4/05 10:49 AM Page 235 Figure 9-11: A simple picture of data from the ERD of Figure 9-10. Figure 9-11 shows a list of primary categories on the left, including items such as Automotive, Collectibles, and Musical Instruments. Only the secondary category for Musical Instruments has been expanded, with vague highlights on secondary categories described in more detail in Figure 9-12. Antiques Art Baby and Toddler Books Cameras Automotive Collectibles Computers Electronics Crafts Movies Health Home and Garden Jewlery Music Musical Instruments Sports Toys Hobbies Video Games 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 1 1 7 7 3 4 6 4 5 2 5 4 3 5 2 3 3 3 5 7 7 3 4 3 2 2 7 1 Acoustic Guitar Electric Guitar Brass Woodwind Alto Horn Alto Saxophone Background Vocals Baritone / Bass Saxophone Baritone Horn Bass Guitar Cello Clarinet Cymbals Double Bass Double Reeds Drum Machines Drums Electronic Drums Fiddle Flugelhorn Flute French Horn Keyboards Latin Percussion Lead Guitar Mellophone Piccolo Rhythm Guitar Primary Primary Secondary Secondary 236 Chapter 9 15_574906 ch09.qxd 11/4/05 10:49 AM Page 236 Figure 9-12: A simple picture of data from the ERD of Figure 9-10. Figure 9-12 shows some of the secondary category listings shown in Figure 9-11, where highlighted items are linked through the tertiary categories and auction listing entries. 1 2 3 4 5 6 7 8 18 19 20 21 22 23 25 26 27 28 29 30 31 32 33 34 1 1 7 7 3 4 6 4 3 5 7 7 3 4 2 2 7 1 4 4 1 4 3 2 Acoustic Guitar Electric Guitar Brass Woodwind Alto Horn Alto Saxophone Background Vocals Baritone / Bass Saxophone Electronic Drums Fiddle Flugelhorn Flute French Horn Keyboards Lead Guitar Mellophone Piccolo Rhythm Guitar Soprano Saxophone Sousaphone Steel Guitar Tenor Saxophone Trombone Trumpet Secondary Secondary 1 2 3 4 5 6 7 8 9 7 7 7 7 7 7 7 7 7 Bagpipes Bassoon Oboe Clarinet Flute Piccolo Recorder Saxophone Other Woodwind Listing Listing Tertiary Tertiary Description Buffet Crampon “Evette” Soprano Sax Saxophone Laurel Alto Saxophone With Case NEW Laurel Tenor Saxophone - Brand NEW w Case Laurel Gold Flute with Case - NEW- A New Bridgecraft Eb Alto Saxophone A New Bridgecraft Flute Handmade Sankyo SR Model Like new!! Price to sell Now!! Vintage Solid Sterling Flute Gorgeous open holed beauty!!! Gold Plated Selmer Mark VI Tenor Sax Early Serial # 57580 BUY_NOW 400.00 2000.00 102.50 9000.00 START_DATE 5/24/2005 14:16 5/24/2005 11:56 5/21/2005 19:15 5/22/2005 19:15 5/22/2005 18:30 5/22/2005 18:30 5/22/2005 16:45 5/22/2005 16:30 5/22/2005 15:20 DAYS 7 7 7 7 7 10 7 7 5 237 Planning and Preparation Through Analysis 15_574906 ch09.qxd 11/4/05 10:49 AM Page 237 Auction House Seller Listings Figure 9-13 shows basic table structure as related to auction listings—the sellers of the listings (the person or organization selling something at auction). Note how indexing is not yet incorporated in this chapter. Indexing is more a design than analysis issue. All that is needed in the analysis stage is basic tables and relationships, including a preliminary field structure for each table. Primary keys, foreign keys, and alternate indexing are not required at this early point in the process of database model creation. Figure 9-13: Adding seller information to the category structure in Figure 9-10. In Figure 9-13, the seller and seller history information has been added with various field items to represent details of both. Figure 9-14 shows a brief view of seller and seller history data. You can see what it looks like in the real world. Figure 9-14 shows the seller and links to various listings, including details such as the name of the seller, popularity with buyers, when the seller joined the online auction house as a seller (when a seller created his or her first auction listing), plus various other bits and pieces of relevant information. Figure 9-15 expands on seller information by adding in a picture of what seller history details would look like. Seller history information would include details such as who the buyer was, what was pur- chased (the auction item listing number), and what the buyer had to say about the seller (comments), among other details. Category_Primary primary Listing listing# description image start_date listing_days currency starting_price reserve_price buy_now_price number_of_bids winning_price buyer Seller seller popularity_rating join_date address return_policy international payment_methods Seller_History seller buyer comment_date listing# comments Category_Tertiary tertiary Category_Secondary secondary 238 Chapter 9 15_574906 ch09.qxd 11/4/05 10:49 AM Page 238 Figure 9-14: A simple picture of seller details data shown in Figure 9-13. Figure 9-15: A simple picture of seller history details data shown in Figure 9-13. Seller History Seller History Seller Seller SELLER Musicians Buddy Musician’s Buddy Sax Man Sax Man Sax Man Sax Man A&C Co A&C Co A &C Co A&C Co BUYER Jim Jones Joe Bloggs Jake Smith Jack the Wack Saxophonist Slow Joe Slim Jim Slim Jim Mark Eric DATE 21-Mar-2000 31-Dec-2003 24-May-1999 28-May-1999 14-Jun-1999 21-Jul-2000 15-Jul-1999 21-Aug-2001 24-Aug-2001 15-Sep-2004 LISTING# 73178497 34999234 34593445 67463564 45645645 45345234 69784561 34554343 33455355 33453457 COMMENTS Very fine item makes me happy. Thanks I bought a great Tenor Sax that arrived sooner than I had expected! Unbeatable price, fast shipping, well packaged Great shipping - very positive experience. Hope to shop with you again. Great seller, Honest, Courteous and Prompt. Will do business again! Nobody beats Kessler. GREAT MOUTHPIECE. Item arrived well packed and exactly as described. Great transaction. first class service, thanks Dave good saxophone Terrific sax SELLER Sax Man Musicians Buddy Instruments Inc. Big Traders A&C Co KellysStuff POPULARITY 100% 98% 85% 100% 100% 100% JOINED 21-May-1999 14-Mar-2000 12-Sep-2004 1-Jan-2005 12-Jun-1998 18-Feb-2001 ADDRESS RETURNS Yes Yes No Undamaged In original packaging No INTERNATIONAL US only UK only Europe Global US only US only PAYMENTS Pay online Personal cheque, MO Cashiers cheque, MO PayOnline ALL ALL Listing Listing Seller Seller Description Buffet Crampon “Evette” Soprano Sax Saxophone Laurel Alto Saxophone With Case NEW Laurel Tenor Saxophone - Brand NEW w Case Laurel Gold Flute with Case - NEW- A New Bridgecraft Eb Alto Saxophone A New Bridgecraft Flute Handmade Sankyo SR Model Like new!! Price to sell Now!! Vintage Solid Sterling Flute Gorgeous open holed beauty!!! Gold Plated Selmer Mark VI Tenor Sax Early Serial # 57580 BUY_NOW 400.00 2000.00 102.50 9000.00 START_PRICE 699.00 99.99 99.99 239.95 109.95 4800.00 600.00 12500.00 BIDS 10 4 25 2 3 START_DATE 5/24/2005 14:16 5/24/2005 11:56 5/21/2005 19:15 5/22/2005 19:15 5/22/2005 18:30 5/22/2005 18:30 5/22/2005 16:45 5/22/2005 16:30 5/22/2005 15:20 DAYS 7 7 7 7 7 10 7 7 5 SELLER Sax Man Musicians Buddy Instruments Inc. Big Traders A&C Co KellysStuff POPULARITY 100% 98% 85% 100% 100% 100% JOINED 21-May-1999 14-Mar-2000 12-Sep-2004 1-Jan-2005 12-Jun-1998 18-Feb-2001 ADDRESS RETURNS Yes Yes No Undamaged In original packaging No INTERNATIONAL US only UK only Europe Global US only US only PAYMENTS Pay online Personal cheque, MO Cashiers cheque, MO PayOnline ALL ALL 239 Planning and Preparation Through Analysis 15_574906 ch09.qxd 11/4/05 10:49 AM Page 239 Historical information allows the auction house to give a popularity rating to a seller, and also allows any future buyers to assess the reputation of a buyer that the sellers may or may not wish to deal with. Auction House Buyers Figure 9-16 adds the buyers to the table structure established so far. A buyer details table and a buyer history table are added. The buyer table has three fewer information fields than the seller details table. Removed fields cover return policies, international sales and shipping, and payment methods. Buyer history is the same as seller history field information. Figure 9-16: Adding buyer information to the category structure in Figure 9-10 (including bids). Information in the two buyer tables would appear much the same as the structural pictures shown in Figure 9-14 and Figure 9-15; however, having built simple ERDs for all tables discovered so far, there are a few important points to note and recount: Category_Primary primary Category_Secondary secondary Category_Tertiary tertiary Bid buyer_bidder seller bid_price bid_price Listing listing# description image start_date listing_days currency starting_price reserve_price buy_now_price number_of_bids winning_price buyer Buyer buyer popularity_rating join_date address Seller seller popularity_rating join_date address return_policy international payment_methods Seller_History seller buyer comment_date listing# comments Buyer_History buyer seller comment_date listing# comments 240 Chapter 9 15_574906 ch09.qxd 11/4/05 10:49 AM Page 240 ❑ Separating buyers and sellers — In any auction model, a buyer can actually also be a seller (bidding on their own items should be prohibited). It might seem sensible to merge the buyer and seller tables, and also merge the two history tables together. Traditionally, in many database models, any types of customer and supplier details are generally separated. This is usually because they are not one and the same, from the perspective of content, as opposed to a structural point of view. In an auctioning database model, separating buyers from sellers is likely to be the most sensible option, simply because it is probably the norm (not always the case) that the buyers are unlikely to be sellers, and visa versa. Obviously, with normalization applied during the design phase (discussed in Chapter 10), it may make sense to separate buyers, sellers, and buyer-sellers (auctioneers who both buy and sell), all into three separate tables. ❑ Referential integrity keys— All the most basic relationships have been established between the different tables. Identifying appropriate primary and foreign keys is more a design issue than an analysis issue. Keys will be established in Chapter 10, which covers design. ❑ Category hierarchy— In some situations, separating static tables (such as the three category tables) may not be the most efficient option. There may be a case for merging all categories into a single table. The single table would contain all three category levels using specialized parent and child fields, for each category record. Because this is once again a design issue and not an analysis issue, it is covered in Chapter 10. Try It Out Analyzing an OLTP Database Model Create a simple analytical-level OLTP database model for a Web site. This Web site allows creation of free classified ads for musicians and bands. Here’s a simplistic approach: 1. Identify the operations of the company. 2. Draw up a picture of basic tables. 3. Establish simple relationships. 4. Create basic fields within each table. How It Works Figure 9-17 shows some basic information categories, both static and transactional in nature. Instruments and skills statically describe relatively static musicians (musicians come and go, skills and instrument classifications do not). This probably makes musicians dynamic transactional information. A band has a specific genre such as playing rock music, punk, classic rock, and so on. Thus, the band is dynamic and the genre is static. The classified advertisement itself is most certainly dynamic in nature. Just in case you are wondering where all this stuff is going (the three points just mentioned), these factors are all design issues, not analysis issues. This chapter deals with the analytical process of discovering basic contents of the auctioning database model. Chapter 10 deals with design issues. The objective of these case study directed chapters is to introduce a data model in a manner that covers each concept step-by-step, making details easy to understand and absorb. 241 Planning and Preparation Through Analysis 15_574906 ch09.qxd 11/4/05 10:49 AM Page 241 Figure 9-17: Identifying basic operations. Figure 9-18 goes just a little further by establishing relationships between the different operations described in Figure 9-17. In other words, musicians play instruments and have skills. Bands are usually of a specific genre. Both musicians and bands can place classified ads to advertise themselves. Figure 9-18: Linking the basic operations. Figure 9-19 shows a briefly constructed ERD as an application of business rules to the operational dia- gram shown in Figure 9-18. There are a number of important points to note: ❑ Musicians can play multiple instruments. ❑ Musicians can be multi-skilled. ❑ A band can have multiple genres. ❑ The MEMBERS field in the band table takes into account the one-to-many relationship between BAND and MUSICIAN. In other words, there is usually more than one musician in a band; how- ever, a musician doesn’t necessarily have to be in a band, a band may be broken up and have no musicians, and both bands and musicians can advertise. ❑ Musicians and bands can place advertisements. Instrument Genre Musician Classified Ad Band Skill Instrument Musician Skill Genre Band Classified Ad 242 Chapter 9 15_574906 ch09.qxd 11/4/05 10:49 AM Page 242 [...]... warehouse is used to contain archived information, separated from the OLTP database, thus not causing performance problems with the OLTP database Establishing Company Operations Company operations have already been established when analyzing the database model for the OLTP database structure All that needs to be done for a data warehouse database model is to establish what are the facts (transactional information),... addresses, is all static information, in that it does not change much The transactional information consists of what is added to the database and then removed from the database after a period of time Transactional information is removed from a database to ensure that the database simply doesn’t get too large to manage; however, all that historical information (such as past bids, and past listings) is... warehouse database models Figure 9-21: A data warehouse star schema database model for the online auction house 244 Planning and Preparation Through Analysis Category Hierarchy Seller Buyer Buyer History Listing Seller History Bids Listing - Bids History Product Location Time Figure 9-22: Analyzing the facts in a data warehouse database model In Figure 9-20, the three categories in the OLTP database. .. product price Figure 9-28: Adjusting the data warehouse database model ERD for an online auction house Figure 9-24 described the analysis and design process of database modeling as being an iterative one Steps can be repeated, in any order, and adjustments can be made during the entire process It is better to make adjustments, particularly at the database modeling stage, during analysis and design Make... application code is written, preferably before any reworking with methodologies (such as normalization and denormalization) have been applied to database models 251 Chapter 9 Try It Out Analyzing a Data Warehouse Database Model Create a simple analytical level data warehouse database model, for the same Web site, as shown in Figure 9-19 Once again, use a simple approach for a simple problem: 1 2 3 4 Identify... the OLTP database model All this “Try It Out” needs is a basic picture of the data warehouse database model, as shown in Figure 9-29 merchandise type price shows Advertisement musician name phone email instruments skills band ad_date ad_text ad_phone ad_email ad_requirements name founding_date genres discography cd_name release_date price Figure 9-29: A basic data warehouse ERD business rules database. .. sketchy ideas of table field content Previously in this chapter, the online auction house OLTP database model already went through the basic business rules application, ERD construction process All that is needed for the data warehouse model is a simple ERD to begin the process of representing that data warehouse database model in a mathematical fashion Figure 9-25 shows such an ERD 248 Planning and Preparation... history_seller_comments buyer popularity_rating join_date address Time month quarter year Product product price Figure 9-25: A data warehouse database model ERD for an online auction house 249 Chapter 9 Most of the fields in the tables shown in Figure 9-25 have already been discussed for the OLTP database model analysis The only fields not covered are the additional locations, time stamp, and product content dimensions:... warehouse database model Products are essentially the same as the online auction house categories Also, the price PRODUCT table PRICE field is irrelevant because there are no fixed prices for each listing category Prices are flexible, determined by a multitude of different sellers, and ultimately the buyers making the bids The PRODUCT table is, therefore, irrelevant to the data warehouse database model... shows a developing star schema for the online auction company data warehouse database model All the dimensions (static information containers) surround the facts (transactional information) in the form of a star schema 245 Chapter 9 Figure 9-21 also shows three newly added dimensions: LOCATION, TIME, and PRODUCT Many data warehouse database models include extra dimensions containing information gleaned . consists of what is added to the database and then removed from the database after a period of time. Transactional information is removed from a database to ensure that the database simply doesn’t get. the OLTP database, thus not causing performance problems with the OLTP database. Establishing Company Operations Company operations have already been established when analyzing the database model. OLTP database model. All this “Try It Out” needs is a basic picture of the data warehouse database model, as shown in Figure 9-29. Figure 9-29: A basic data warehouse ERD business rules database

Ngày đăng: 03/07/2014, 01:20

Từ khóa liên quan

Mục lục

  • cover.pdf

  • page_c2.pdf

  • page_r01.pdf

  • page_r02.pdf

  • page_r03.pdf

  • page_r04.pdf

  • page_r05.pdf

  • page_r06.pdf

  • page_r07.pdf

  • page_r08.pdf

  • page_r09.pdf

  • page_r10.pdf

  • page_r11.pdf

  • page_r12.pdf

  • page_r13.pdf

  • page_r14.pdf

  • page_r15.pdf

  • page_r16.pdf

  • page_r17.pdf

  • page_r18.pdf

Tài liệu cùng người dùng

Tài liệu liên quan