views:

34

answers:

1

Hello guys... Can you help-me with that database :

alt text

I´m using Fluent NHibernate, but XML helps too... My problem is with ProductPrice table...

Thanks

Paul

+2  A: 

Nothing special...

<class name="ProductPrice">
  <id name="Id">
    <generator class="..."/>
  </id>
  <property name="Price"/>
  <property name="IsSale"/>
  <property name="PriceSale"/>
  <property name="Sku"/>
  <many-to-one name="ProductSize" column="SizeProductFk"/>
  <many-to-one name="ColorProduct" column="ColorProductFk" />
</class>

Of course you have to map ProductSize and ColorProduct as entities.

Diego Mijelshon
Thanks Diego...But I have another problem... Example: How can I get all ProductPrice with Product Id = 4 per example? Maybe my database design is not good/corret to solve that problem easyly...
Paul
HQL example: `from ProductPrice pp where pp.ProductSize.Product.id = 4`. There's nothing wrong with your design.
Diego Mijelshon
Thanks...But in some cases the product has no color or size... So, How can I get his price?
Paul
If a product can have no color or size, then you're missing a relationship between price and product.
Rich
Which kind of relationship are you talking about?
Paul
@Paul, You have to state your requirements up front. If a Product can have a price without Size nor Color, then your DB design is wrong, no matter how you query it.
Diego Mijelshon
Yes... Do you have any suggestion ? Thanks
Paul
Yes, you need a direct relationship from ProductPrice to Product. You can keep the relationships to ProductSize and ColorProduct, or map directly to Product, Color and Size (in which case you might end removing ProductSize and ColorProduct, depending on your needs)
Diego Mijelshon