KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Document oriented databases (particularly RavenDB) are really intriguing me, and I'm wanting to play around with them a bit. However as someone who is very used to relational mapping, I was trying to think of how to model data correctly in a document database. Say I have a CRM with the following entities in my C# application (leaving out unneeded properties): public class Company { public int Id { get; set; } public IList<Contact> Contacts { get; set; } public IList<Task> Tasks { get; set; } } public class Contact { public int Id { get; set; } public Company Company { get; set; } public IList<Task> Tasks { get; set; } } public class Task { public int Id { get; set; } public Company Company { get; set; } public Contact Contact { get; set; } } I was thinking of putting this all in a Company document, as contacts and tasks do not have a purpose out side of companies, and most of the time query for a task or contacts will also show information about the associated company. The issue comes with Task entities. Say the business requires that a task is ALWAYS associated with a company but optionally also associated with a task. In a relational model this is easy, as you just have a Tasks table and have the Company.Tasks relate to all tasks for the company, while Contact.Tasks only show the tasks for the specific Task. For modeling this in a document database, I thought of the following three ideas: Model Tasks as a separate document. This seems kind of anti-document db as most of the time you look at a company or contact you will want to see the list of tasks, thus having to perform joins over documents a lot. Keep tasks that are not associated with a contact in the Company.Tasks list and put tasks assocaited with a contact in the list
Tags (comma-separated)
Save Edits
Cancel