4

When it comes to laying out tables in transact SQL databases, like SQL-Server and Sybase, the classic approach to relational modelling is well established. (The authority being Halpin's book)

  1. Establish your use cases
  2. Establish your entities
  3. Determine the attributes of the entities
  4. Determine the relationship between the entities
  5. Layout the tables with the joins to satisfy the use cases in the query
  6. Refactor the tables to nth normal form as required.

(or some variation thereon).

For Cassandra databases - this pattern is slightly modified, in that you have to start with your use cases, and then design for zero joins at query time. (The authority for this approach is the datastax training documentation).

You could say that you leave your tables fully denormalised at the level of the query for your use-case. So the pattern is more similar to:

  1. Establish your use cases
  2. Establish your entities
  3. Determine the attributes of the entities
  4. Determine the relationship between the entities
  5. Layout the tables denormalised to satisfy the use cases in the query

Now MongoDb is a document based database with the ability to do joins.

My question is: What is the canonical pattern for database design with MongoDB?

Tulains Córdova
  • 39,201
  • 12
  • 97
  • 154
hawkeye
  • 4,819
  • 3
  • 24
  • 35
  • 4
    There's plenty of information about this on the Internet already, if you care to look. For example, this: https://www.tutorialspoint.com/mongodb/mongodb_data_modeling.htm – Robert Harvey May 12 '17 at 14:16
  • 1
    I voted to close your question because it is too broad. Teaching database design from scratch is not something we do here. Ask a more specific question like "How are joins handled in MongoDB?" – Robert Harvey May 12 '17 at 14:31
  • Thanks @RobertHarvey for the link. Perhaps you can explain why this approach is different to the two patterns above. (I respectfully contend that this question is not too broad for a site about software engineering). – hawkeye May 13 '17 at 04:56
  • 1
    There's no "connect the dots" to be done here... you have to *design a database.* Stop looking for patterns to follow and break out your design skills. – Robert Harvey May 13 '17 at 13:42

1 Answers1

0

Based on the helpful information provided by @RobertHarvey - we can see that the MongoDB design process is similar to Cassandra's design process. (Whilst it has joins - you shouldn't use them for reading data in a query).

So the process will look like this:

  1. Establish your use cases
  2. Establish your entities
  3. Determine the attributes of the entities
  4. Determine the relationship between the entities
  5. Layout the tables with the joins to satisfy the use cases in the query
  6. Refactor the tables to nth normal form as required.
hawkeye
  • 4,819
  • 3
  • 24
  • 35