While working on implementing voucher feature for an eCommerce application, I need to implement Voucher usage restriction, some of restriction I am planning to have

在为电子商务应用程序实施凭证功能的同时,我需要实施凭证使用限制,我计划的一些限制

  1. Products
  2. 制品
  3. Exclude products
  4. 排除产品
  5. Product categories
  6. 产品类别
  7. Exclude categories
  8. 排除类别
  9. Email /Customer restrictions
  10. 电子邮件/客户限制

Currently We are supporting following 2 type of Vouchers with an option to create Custom voucher type and all those Vouchers types are being maintained in a single table with help of discriminator (Hibernate use).

目前我们支持以下2种类型的优惠券,可以选择创建自定义凭证类型,所有这些优惠券类型都借助于鉴别器(Hibernate使用)在单个表中进行维护。

  1. Serial Vouchers
  2. 串行优惠券
  3. Promotion Vouchers.
  4. 促销优惠券。

these are only few which I am targeting at initial stage.My main confusion is about database design and restriction of these voucher usage with Voucher.I am not able to decide which is best way to Map these restrictions in database.

这些只是我在初期阶段所针对的几个。我主要的困惑是数据库设计和使用凭证限制这些凭证的使用。我无法确定哪种是在数据库中映射这些限制的最佳方法。

Should I go for a single table for all these restriction and have a relation with Voucher table or is it good to group all similar type of restriction in a single table and have their relation with Voucher table.

我应该针对所有这些限制使用单个表并与Voucher表关联,还是将所有相似类型的限制组合在一个表中并与Voucher表关联。

As an additional information , we are using hibernate to map our entities with the DB table.

作为附加信息,我们使用hibernate将我们的实体映射到DB表。

4 个解决方案

#1


4

This seems like a very wide-open and freeform requirement. Some questions:

这似乎是一个非常开放和自由形式的要求。一些问题:

How complex will the business rules you are attempting to model be? If you’re allowing (business) users to define their own vouchers, odds are good they’ll come up with some pretty byzantine rules and combinations. If you have to support anything they come up with, you will have problems.

您尝试建模的业务规则有多复杂?如果您允许(商业)用户定义他们自己的优惠券,可能性很高,他们会提出一些漂亮的拜占庭式规则和组合。如果你必须支持他们想出的任何东西,你就会遇到问题。

What will the database be tasked to do with this data? Store the “voucher definition”, sure, but then what? Run tallies or reports on them? Analyze how many are used, by who/when/how/for what? Or just list out what was used/generated over the past year?

数据库应该对这些数据做什么?确定存储“凭证定义”,但那又是什么?运行计数或报告?分析使用了多少,按谁/何时/如何/用于什么?或者只列出过去一年中使用/生成的内容?

What kind of data volumes are you going to have? One entry per voucher definition, or per voucher printed/issued? (If the latter, can you use one entry per voucher, with a count of how many issued?) Are we talking dozens, hundreds, or millions of vouchers?

你将拥有什么样的数据量?每张凭证定义一个条目,或打印/签发的每张凭证? (如果是后者,您是否可以使用每个凭证一个条目,并计算已发放的数量?)我们是在谈论几十个,几百个还是数百万个优惠券?

If it’s totally free-form, if they just want a listing without serious analysis, if the overall volume is small, consider using blob fields rather than minutiae-oriented columns. Something like a big text field and a data-entry box wherein the user will “Enter any other criteria defining the voucher”. (You might even do this using XML.) Ugly, you can’t readily analyze the data, but if the goals are too great or diffuse and you're not going to use all that detailed data, it might be necessary.

如果它是完全自由形式的,如果他们只是想要一个没有认真分析的列表,如果总体积很小,考虑使用blob字段而不是面向细节的列。类似于大文本字段和数据输入框的用户将“输入定义凭证的任何其他标准”。 (你甚至可以使用XML来做这件事。)丑陋,你不能轻易地分析数据,但如果目标太大或太分散而且你不打算使用所有那些详细数据,那么可能是必要的。

A final note: a voucher that is good for only selected products cannot be used on products that are added after the voucher is created. A voucher that is good for all but selected products can be used for subsequently created products. This logic may apply to any voucher-limiting criteria. Both methodologies have merit, make sure the users are clear on what they’re doing.

最后一点:只有选定产品的优惠券不能用于创建优惠券后添加的产品。除了所选产品之外的所有产品均可使用的优惠券可用于随后创建的产品。该逻辑可适用于任何凭证限制标准。这两种方法都有其优点,确保用户清楚他们正在做什么。

更多相关文章

  1. 字体图标的引入和通过媒体查询改变导航样式
  2. HTML样式和常用选择器
  3. 字体图标的引用和自定义样式/媒体查询的使用
  4. 数据库的CURD操作、PDO本质与原理的学习
  5. CSS之伪类选择器和简单盒子简单案例
  6. 伪类选择器与盒模型常用属性
  7. 伪类选择器-结构伪类、根据位置选择匹配
  8. 7.4——常用标签与应用场景之表格与单元格
  9. css伪类选择器和盒模型

随机推荐

  1. 接着很久以前的贪吃蛇
  2. redis框架搭建实战(持续更新)
  3. Android ListView获取当前可视区域条目数
  4. Java编程思想总结笔记Chapter 5
  5. Android与PC蓝牙交互
  6. Android实现夜间模式
  7. JAVA 虚拟机学习整理 一、基本结构
  8. java根据URL获取网页编码
  9. android-----关于事件分发机制中几点困惑
  10. 理解Java注解(java.lang.annotation)