Iii. Design and Development of database management software for multiple users and their permission management. It is impossible to ignore the issue of multi-user and user permission settings. Although the large and medium-sized back-end database system software on the market currently provides multiple users and the permission setting function for a table in a database, I personally suggest: A mature set of database management software should still design the user management function on its own, for two reasons: 1. the multi-user and permission settings provided by the large and medium-sized background database system software are aimed at the common attributes of the database and may not fully meet the requirements of some special cases; 2. do not rely too much on some special functions of the background database system software. A variety of large and medium-sized background database systems are not fully compatible with each other. Otherwise, the previous architecture design may not be reused once the database platform or background database system software version needs to be changed in the future. The following describes how to design a flexible multi-user management module. That is, the system administrator of the database management software can add new users, modify the permissions of existing users, and delete existing users. First, analyze the user requirements and list all the functions that need to be implemented by the database management software. Then, sort these functions according to certain contacts, that is, classify the functions that a certain user needs into one category; create a table at last: The name type constraint of the function (Function_table) indicates that f_id int does not have a repeated Function Identifier. The primary key f_name char (20) cannot be a blank function name, repeated f_desc char (50) is not allowed to be empty function description user group table (User_group) Name type constraints description group_id int no repeated user group identification, primary key group_name char (20) empty user group name group_power char (100) is not allowed. Empty user group permission table is not allowed. Set User table (User_table) whose content is f_id) name type constraints indicate that the user_id int has no duplicate user IDs, and the primary key user_name char (20) has no duplicate username user _ Pwd char (20) is not allowed to be empty User Password user_type int is not allowed to be empty belong to the user group identification, and associated with User_group.group_id using this user group architecture design, when you need to add new users, you only need to specify the user group to which the new user belongs. When the system needs to add new functions or modify old function permissions in the future, only the operation menu and user group table records are used, the functions of the original users can change accordingly. Of course, this architecture design moves the function determination of the database management software to the front-end, making the front-end development more complex. However, when the number of users is large (more than 10) or the probability of software upgrade is high in the future, this price is worthwhile. 4. The simple batch m: n design involves the m: n relationship. Generally, three tables are created, m, n, and m: n. However, m: n sometimes encounters batch processing. For example, to borrow books from the library, users are generally allowed to borrow n books at the same time. If you want to query borrowing records by batch, that is, how to design a list of all books borrowed by a user? Let's create three required tables first: Book table (Book_table) Name type constraints description book_id int no duplicate book id, primary key book_no char (20) no duplicate book number book_name char (100) cannot be empty book name ...... Borrowing User table (Renter_table) Name type constraints description renter_id int no Duplicate User ID, primary key renter_name char (20) cannot be blank user name ...... The type constraints of the name Type of the borrow record table (pai_log) indicate that the reserved _id int does not have a duplicate borrow Record ID. The primary key r_id int cannot be an empty user ID, and the B _id int associated with Renter_table.renter_id cannot be an empty book id, when you associate it with Book_table.book_id, The rent_date datetime cannot be empty ...... To query borrowing records by batch, we can create another table to store the information of batch borrowing, for example, Batch_rent) the name type constraints indicate that the batch_id int does not have a duplicate batch borrowing ID. The primary key batch_no int cannot be an empty batch borrowing number. The same batch of borrowing batch_no has the same consumer _id int and cannot be an empty borrowing record ID, is it better to associate batch_date datetime with pai_log.mongo_id with a design that does not allow empty batch borrowing time? Let's take a look at how to query to list all the books borrowed by a user? First, retrieve the Batch_rent table, save the data in the region _id field of all records that meet the conditions, and then use the data as the query conditions to bring the data to the borrow _log table for query. So, is there any way to improve it? The following provides a simple batch design scheme. You do not need to add a new table. You only need to modify the borrowing record table (pai_log. The modified record table (pai_log) is as follows: the type constraints of the borrow record table (pai_log) name indicate that the unique _id int has no duplicate record identification, and the primary key r_id int cannot be an empty user identification, the B _id int associated with Renter_table.renter_id cannot be empty book IDs, and the batch_no int associated with Book_table.book_id cannot be empty batch borrow numbers, the same batch of borrowed batch_no has the same mongo_date datetime and cannot be empty. The same batch of borrowed batch_no has the same mongo_id as the first batch of borrowed data. For example, if the maximum shard _id is 64 and a user borrows three books at a time, the batch_no values of the three borrowing records inserted in batch are 65. Then another user rented a set of discs and inserted the portable _id of the rental record as 68. With this design, you only need to use a standard T_ SQL nested query to query the batch borrowing information. Of course, this design does not comply with 3NF, but which one is better than the above standard 3NF design? I don't need to say the answer. 5. Select redundant data. A redundant field is retained in the "tree-based data table" in the previous article. The example here goes further-a redundant table is added. Let's take a look at the example: in order to solve the employees' work meals in my original company, I contacted a nearby small restaurant and recorded the meals every day. The expenses were shared by the number of people and settled by the company's cash at the end of the month, each person's work meal fee is deducted from the employee's salary every month. Of course, the number of people who eat each day is not fixed, and the cost of each meal varies according to the color of the dishes selected for each work meal. For example, five people spent 40 yuan for lunch on Monday, 20 yuan for dinner, 36 yuan for lunch on Tuesday, and 18 yuan for dinner. To facilitate the calculation of each person's work meal fee per month, I wrote a simple dining accounting management program. There are three tables in the database: employee table (Clerk_table) name type constraints description clerk_id int no duplicate employee ID. The primary key clerk_name char (10) is not allowed to be empty employee names per meal summary table (Eatdata1) name type constraints indicate that totle_id int has no duplicate table IDs for each meal, primary key persons char (100) an empty dining employee's staff identification set eat_date datetime is not allowed. An empty dining date eat_type char (1) is not allowed, it is used to distinguish between the middle and dinner totle_price money cannot be empty. The total consumption of each meal is persons_num int) the name type constraints indicate that the id int does not repeat the billing table id, and the primary key t_id int cannot be Empty table id for each meal, associated with Eatdata1.totle _ id c_id int is not allowed to be empty employee id, and associated with Clerk_table.clerk_id price money is not allowed to be empty, each meal is spent, dining billing table (Eatdata2) the record is to split one record of each meal table (Eatdata1) by dining staff. It is a redundant table without compromise. Of course, you can also combine some fields of the Eatdata1 table into the Eatdata2 table, so that the Eatdata1 table becomes a redundant table, however, the design of the dining billing table has more duplicate data, which is better than the above solution. However, the redundant table Eatdata2 simplifies programming while collecting the monthly meal fee statistics, you can use a query statement like this to calculate the number of meals sent per month and the general ledger of meals: SELECT clerk_name AS personname, COUNT (c_id) as eattimes, SUM (price) AS ptprice FROM Eatdata2 JOIN clerk_tabsystemic ON (c_id = clerk_id) JOIN eatdata1 ON (totleid = tid) WHERE eat_date> = CONVERT (datetime, '"& the_date &"') AND eat_date <DATEADD (month, 1, CONVERT (datetime, '"& the_date &"') group by c_id. If you do not need this redundant table, every time you count the total monthly meal fee for each person It will be a lot of trouble, and the program efficiency is also awkward. So when can we add some redundant data? I think there are two principles: 1. the overall needs of users. When the user pays more attention to the data that is listed after the database standard records are processed according to certain algorithms. If the algorithm can be completed directly using the built-in functions of the background database system, you can add redundant fields or even redundant tables to store the data processed by the algorithm. You must know that the efficiency of the background database system for querying, modifying, or deleting large volumes of data is much higher than that of the code we write. 2. simplify development. There are many methods to implement the same functions in modern software development. Although programmers do not need to be proficient in the vast majority of development tools and platforms, they still need to know which method to use with which development tool programs are more concise and more efficient. The essence of redundant data is to use space for time, especially the current development of hardware is much higher than that of software, so proper redundancy is acceptable. However, I would like to emphasize at the end that we should not rely too much on the features of platforms and development tools to simplify development. If we are not sure about this degree, we will continue to maintain and upgrade later.