Mongodb data structure of some questions boss please come in!

first contact with nosql
there are some questions about the table structure
such as designing a game user table
should the user"s backpack be included in the user table or create a separate table?


//  user
{
    _id: "",
    name: "",
    email: "",
    ....
    backpack: [
        {
            // 1
        },
        {
            // 2
        }
    ]
}
// 
//  user
{
    _id: "",
    name: "",
    email: "",
    ...
}

// 
{
    _id: "",
    user_id: "",
    ...
}

solve! Thank you!

Mar.10,2021

this is a simple data problem, involving the database.
personal advice is to set up separately and associate through foreign key constraints.


can be nested in the user table:
{

'_id':ObjectId("52ffc33cd85242f436000001"),
'name':'Jackey',
backpack: {
    'backpack_color': 'white'
}

}
like this, if the number is increasing, consider the index:
is to create a table separately, and then put it in the user table in the id that references the knapsack table

.

this question should be considered like this:
the number and attributes of your backpack are certain, and you are an individual. It can also be used in other places, not just for users: this is about creating a knapsack table that has nothing to do with the user

.

then your user is also a separate individual, and you should also create a separate user table

then you have a many-to-many relationship between the user and the backpack, so all you have to do is create a table associated with the user's backpack in

.

in this case, you don't need to update the tables of users and backpacks frequently, you just need to pay attention to the associated tables to add, delete and modify

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b34a22-2b6a8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b34a22-2b6a8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?