0

I have recently started learning NoSQL databases, and I am currently working in MongoDB. I have a question regarding the design of the database, specifically how would an IsA relationship translate to a NoSQL database? Say I have a database with employees and customers, both have accounts that include "email, name, password, etc..", how would I design this?

I see 2 options based on what I have learned so far:

1- Include all of the fields in both of the models
2- Create an account parent model, and add a reference to the account inside each of the employee and customer models

Is there an option that I am not aware of that would be perfect for this kind of design?

  • perhaps separate out the common data into a user record and use references to link other data (you could also have a user_type field)? – jspcal Apr 09 '21 at 00:07
  • So in the user record (common data), I would add a user_type field that would indicate whether it's a customer or an employee, I am guessing this is not required but is good to have? And then, in the other data, I would include the id of the user record as a reference? – ZeeInTheFlow Apr 09 '21 at 00:11
  • Does this answer your question? [How can you represent inheritance in a database?](https://stackoverflow.com/questions/3579079/how-can-you-represent-inheritance-in-a-database) – philipxy Apr 09 '21 at 01:41

0 Answers0