Application scenario: the background management system assigns visible menu permissions to the created users. For example, if user An is assigned 10 menus, then the user can see the 10 menus in the menu bar after logging in. Now the menu is up to 3 levels. According to the current business, the maximum number of menus assigned by a single user is no more than 30.
now the database uses MongoDB, to store menu permissions in two ways:
- menu list, that is, a menu list is stored in each user permissions table, so that all menus under that user can be seen in a single query record.
- menu items are tiled, with each row of records corresponding to a user"s menu, so that if the user sees 20 menus, there will be 20 rows of records in the table.
scheme 1 is that it is convenient to store, and all menu lists can be returned by a single record when querying; the advantage of scheme 2 is that it is convenient to find out which users are given a menu to see.
individuals prefer option 2, but are not sure whether it is a common design approach. Do you have any suggestions? Thank you!