0

Trying to summarize in as few of words as possible:

I am trying to create a system that tracks the various products an individual can sell and the commission percentage they earn on that particular item. I am thinking about creating reference integers for each product called "levels" which will relate to their commission percentage in a new lookup table instead of a single reference point.. Is this overkill though or are there any benefits over just placing inline for each record?

My gut tells me there are advantages of design 1 below but not sure what they are the more I think about it. If I need to update all individuals selling product X with level Y, indexes and replaces make that easy and fast ultimately in both methods. By using design 2, I can dynamically change any "earn" to whatever percentage I can come up with (0.58988439) for a product whereas I would have to create this "level" in design 1.

Note: the product does not relate to the earn diretly (one sales rep can earn 50% for the same product another sales rep only earns 40% on).

Reference Examples:

Design 1 - two tables

table 1

ID  |  seller_id   |   product_id   |   level
-----------------------------------------------
1   |   11111      |     123A       |    2
2   |   11111      |     15J1       |    6
3   |   22222      |     123A       |    3

table 2

ID  | level |   earn
--------------------------
1   |   1   |   .60
2   |   2   |   .55
3   |   3   |   .50
4   |   4   |   .45
5   |   5   |   .40
6   |   6   |   .35

Design 2 - one table

ID  |  seller_id   |   product_id   |   earn
-----------------------------------------------
1   |   11111      |     123A       |    .55
2   |   11111      |     15J1       |    .35
3   |   22222      |     123A       |    .45

(where earn is decimal based, commission percentage)

Update 1 - 7/9/13

It should also be noted that a rep's commission level can change at any given time. For this, we have planned on simply using status, start, and end dates with ranges for eligible commission levels / earn. For example, a rep may earn a Level 2 (or 55%) from Jan 1 to Feb 1. This would be noted in both designs above. Then when finding what level or percentage a rep was earning at any given time: select * from table where (... agent information) AND start <= :date AND (end > :date or END IS NULL)

4

2 回答 2

3

对企业有什么意义吗level

例如,我可以想象一个级别是管理单位的情况。也许有一个季度的销售热潮,每个级别的费率都会发生变化。或者,是否有分级报告?在这些情况下,有一个单独的“级别”表是有意义的。

另一种情况是产品的不同价格有不同的水平——也许你卖得越高,佣金就越高。或者,佣金可能是基于门槛的,所以今年卖得足够多的人突然得到更高的佣金。

换句话说,可能有很多关于佣金的规则超出了原始百分比。在这种情况下,“规则”表将是数据模型的必要部分(“级别”是特定类型的规则)。

另一方面,如果您没有任何此类规则并且佣金始终基于人和产品,那么将百分比存储在表格中很有意义。它简单易懂。它在访问百分比时也具有良好的性能——这可能比更改它更频繁地发生。

于 2013-07-08T23:28:41.410 回答
2

首先,使用值来引用查找表与规范化本身id无关。上面显示的设计#2 是标准化的。很多人对标准化有这种误解。

使用查找表(设计#1)的一个优点是您可以更改级别 6 获得的内容(例如),并且通过更新查找表中的一行,您会隐式影响引用该级别的所有行。

而在设计#2 中,您必须更新每一行以应用相同的更改。这不仅意味着更新许多行(这会影响性能),而且还可能导致您无法执行与所有需要更新的行匹配的正确 UPDATE。因此,对于应该相同的收入水平,某些行可能具有错误的值。

同样,在许多情况下使用查找表可能是一个好主意,将其称为normalization是不正确的。

于 2013-07-08T23:10:57.923 回答