1. Trang chủ
  2. » Công Nghệ Thông Tin

Beginning Database Design- P14 pot

20 231 0
Tài liệu đã được kiểm tra trùng lặp

Đ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

Thông tin cơ bản

Định dạng
Số trang 20
Dung lượng 785,4 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Auction House Categories Figure 9-9 shows a data picture of some of the structural table elements shown in Figure 9-8.. Starting with the categories static structures in Figure 9-3, the

Trang 1

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 rules

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

Trang 2

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

Instrument

Trang 3

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

Trang 4

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

Trang 5

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

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

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 SaxophoneNEW-

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

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

Trang 6

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

Trang 7

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

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

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 SaxophoneNEW-

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

Trang 8

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

Trang 9

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

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.

Trang 10

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

BANDand 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

Skill

Instrument

Musician

Skill

Genre

Band

Classified Ad

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

TỪ KHÓA LIÊN QUAN