数据库设计,多类客户同表 [英] Database design, multiple types of customers in the same table

查看:27
本文介绍了数据库设计,多类客户同表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

业务场景:

  • 客户可以使用他们的电子邮件地址作为登录名登录到在线电子商务应用程序.

  • Customers can login to an online e-Commerce app, using their e-mail addresses as their logins.

我们有一个依赖同一个数据库的 CRM 应用.员工使用 CRM 应用程序添加非在线客户,电子邮件不是此处的必填字段.

We have a CRM app that depends on the same database. Employees use the CRM app to add non-online customers, and e-mail is NOT required field here.

技术上:在 Customer 表中没有什么自然地"进行 PK.无论如何,即使没有自然PK,我也总是使用人工PK.我担心这最终会导致搜索、完整性等方面的问题.不过,我无法确定会出现哪些问题.

Technically: There is nothing "naturally" making a PK in Customer table. Regardless, I always use an artificial PK even if there is no natural one. I'm worried that this will eventually lead to problems in searching, integrity, etc. I can't determine exactly what problems will come up, though.

我认为开发人员不会期望电子邮件列允许空值,并且他们会创建忽略这种情况的程序.

I think developers won't expect the e-mail column to allow null, and they will create programs ignoring this situation.

请记住,整个系统,以及大部分数据库都会依赖于客户数据,如果客户表出现问题,很可能会被其他表继承.

Remember that the whole system, and most of the database will depend on customer data, if something goes wrong in the customer table, it will probably be inherited by the other tables.

两种客户的存在让我脑中出现异常,但我无法弄清楚异常的信息.你怎么认为?现在寻找出路更好吗?或者你认为,没关系,就这样一直到出现问题为止,因为它不太可能引起问题,记住问题不是必要的错误,它可能是可维护性或开发并发症?

谢谢

推荐答案

将这些数据放在同一个表中是否有特定的原因?CRM客户"和电子商务客户是否共享此数据库中的许多其他表?

Is there a specific reason to put these data together in the same table? Do CRM "customers" and e-commerce customers share many other tables in this database?

老实说,我不会把电子商务客户放在这个数据库中.尽管您可以创建视图来轻松分离电子商务和 CRM 数据,但这对我来说似乎完全没有必要.此外,您还没有描述电子商务和 CRM 数据需要存在于同一个数据库中的任何特殊原因.也许你没有在问题中包含一个原因,但如果你问我,这已经很臭了.

Honestly, I would not put e-commerce customers in this database. Although you can create views to easily separate e-commerce and CRM data, this seems totally unnecessary to me. Furthermore, you haven't described any particular reason why e-commerce and CRM data need to live in the same database. Maybe there's a reason you didn't include in the question, but this already smells if you ask me.

根据您在此处提供的信息,我认为为电子商务客户创建单独的数据库和表格不会有任何重大损失.将不相关的数据分开.

From the information you've included here, I don't think you're losing anything significant by creating a separate database and table for the e-commerce customers. Keep unrelated data separate.

更明确地说:如果您的电子商务客户不与 CRM 客户共享大量数据,请创建新的客户表.如果他们确实共享了大量数据,那么一个空列可能不是世界末日.

To make this extra clear: if your e-commerce customers do not share a lot of data with the CRM customers, create new customer tables. If they do share a lot of data, then one null column is likely not the end of the world.

这篇关于数据库设计,多类客户同表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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