I am using MySQL and have an articles
table which has 2 columns: currency
and price
, but an article can also have a negotiated price
, so I can't determine currency
and price
values.
What should I开发者_开发技巧 do to be able to have defined and negotiated prices?
If the negotiated price is specific to a user/business... , then this is probably a one to many relationship, you will need a tuple table to hold the price and link the article to the other object.
e.g: (I'll assume the price is negotiated with a user)
CREATE TABLE user_article_price (
articleid INT,
userid INT,
price DECIMAL(13,2)
)
You then simply need to LEFT JOIN
to this table and use NVL(user_article_price.price, article.price)
to get the overridden value.
Note: It is probably a good idea to make a compound primary key using the 2 id columns to stop duplicate values.
精彩评论