简体   繁体   中英

Database schema design: more optimal schema

I'm going to build a schema for the following XML file:

<Item ItemID="1045677572">
<Bids>
    <Bid>
        <Bidder Rating="1097" UserID="catann1">
            <Location>Longmont, Colorado</Location>
            <Country>USA</Country>
        </Bidder>
        <Time>Dec-10-01 06:43:24</Time><Amount>$0.99</Amount>
    </Bid>
...
</Bids>
<Seller Rating="87" UserID="efritz68"/>
</Item>

XML: Location and Country information is optional for Bidder. But, Seller don't need that information. A bidder can be a seller at the same time. A user may bid on multiple items. In that case, his Rating, Location, and Country information are the same across all bids. A user may have two separate ratings as a bidder and a seller, in case the seller is also bidding on other item(s)

I'm not sure which schema is more optimal to store Users. Here's my schema:

1)

  • User (UserID, Location, Country)
  • Bidder (UserID, Rating)
  • Seller (UserID, Rating)

2)

  • Bidder (UserID, Rating, Location, Country)
  • Seller (UserID, Rating)
  • User (UserID)

Your schema is (whether you like it or not):

Item (ItemID, SellerUserID, ...)
User (UserID, BidRating, SellRating, ...)
Bid (UserID, ItemID, Amount, Timestamp, ...)

Your XML is a denormalized version of this schema.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM