Database design, multiple types of customers in th

2019-07-26 05:44发布

问题:

Business scenario:

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

  • 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.

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.

The existence of two types of customers fires exceptions in my brain, but I can't figure out the exception's message. What do you think? Is it better to find some way out now? Or you think, it is ok, leave it like this till something goes wrong, because it is not likely to cause a problem, Remember that the problem is not a bug by neccissary, it can be maintainability or development complications ?

Thanks

回答1:

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?

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.

Edit:

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.