在设计中的SQL Server表需要咨询 [英] Need advice in designing tables in SQL-Server

查看:150
本文介绍了在设计中的SQL Server表需要咨询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含(表QuoteItem店)项目报价:结果
QuoteItemId,QuoteId,ITEMID,数量等。

I have a quote that contains items (store in table QuoteItem):
QuoteItemId, QuoteId, ItemId, Quantity etc.

现在,我需要能够创建一个组中的报价选择的项目,并在其应用的折扣。
嗯,这很简单,我创建两个表:结果
组:GroupId的,DiscountPercentage结果
GroupQuoteItem:GroupId的,QuoteItemId

Now, I need to be able to create a group of chosen items in the quote and apply a discount on it. Well that's simple, I create two more tables:
Group: GroupId, DiscountPercentage
GroupQuoteItem: GroupId, QuoteItemId

让我们说我有一个报价30项。
我做了一个包含项目从报价1-20个组,我申请上的折扣。
现在我需要有一个包含项目10-30另一组,问题是那些内10个项目,我需要控制的折扣是否应该给对方折扣后敷在项目或应该上的项目底价。结果
比如,我要去谈项目没有。 15报价:QuoteItem.Cost = 100
我申请的10%= 90。结果第一个折扣
现在,我想申请第二个折扣,我需要能够控制如果折扣应在100应在90结果
同样的是,当我有多个团体折扣,当我想申请折扣的复杂的架构。

Let's say I have 30 items in a quote. I made a group that contains items 1-20 from the quote and I applied a discount on it. Now I need to have another group that contains items 10-30, the problem is about those inner 10 items, I need to control whether the discount should apply on the items after the other discount or it should be on the items' base price.
For instance, I am gonna talk about item no. 15 in the quote: QuoteItem.Cost = 100 I applied 1st discount of 10% = 90.
Now I want to apply the second discount, I need to be able to control if the discount should be on the 100 or should be on the 90.
Same is when I have multiple discount groups and when I wanna apply a complex architecture of discounts.

任何帮助将是非常美联社preciated。

Any assistance will be really appreciated.

推荐答案

我会考虑添加一列到GroupQuoteItem表,GroupQuoteItem.Priority。本栏目将在确定最终价格查询使用。如果你有N个折扣与相同,最高的优先级,他们将彼此相叠(顺序无所谓,感谢乘法的关联性)。

I would look into adding a column to the GroupQuoteItem table, GroupQuoteItem.Priority. This column would be used in the query that determines the final price. If you have N discounts with the same, highest priority, they will be stacked atop each other (the order doesn't matter, thanks to associativity of multiplication).

如果所有这些高优先级的折扣是后取下,低优先级的折扣可以采取自己的位置。这应该可以帮助您设置pretty复杂的折扣结构。

If all of these high-priority discounts are later removed, lower-priority discounts can take their place. This should help you in setting up pretty complex discount structures.

我希望,至少给你的地方,从启动。

I hope that at least gives you somewhere to start from.

这篇关于在设计中的SQL Server表需要咨询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆