Reputation: 579
I'm new to MongoDB and I would like to get some advice about how to design my database schema.
I'm currently trying to develop a private Events manager using the Sails.js framework for Node.js
Each users of the application will be able to create events and manage guests for each one.
Design #1: (similar to what I would do with MYSQL)
2 collections: users and guests.
Guests are linked to users using a foreign key guest_id
Design #2:
1 users collection using embedded documents
{
"id": "integer",
"name": "string",
"guests": [
{
"id": "integer",
"firstname": "string",
"lastname": "string",
"attended": "boolean",
"email": "string",
"phone": "string",
"addresse": {
"street": "string",
"zipcode": "integer",
"city": "string",
"country": "string",
},
"notes": "text"
}
],
Design #3:
2 collections: Users and Guests.
In guests, each document has an ID and a arrays of people
Design #4:
Using dynamic collections
Each user's guests will be store in one collection named guests_$userid
The thing is I don't know if I can do it with Sails.js
Thank you in advance for your help.
I really want to learn the good practice when designing NoSQL databases and be sure to understand and use all the potential of it.
Upvotes: 0
Views: 1056
Reputation: 5979
You can do 1 - 3 with sails/waterline
You can do 4, but not with waterline, you would have to use a different ORM
As far as the rest of your question goes, it is subject to many variables and is pretty much opinion based.
Upvotes: 1