The idea of connecting to a post is that I don't want to query the remarks field every time I query, but I don't want to write very good SQL statements every time. Although I can use some SQL statement generators, but after all, the simpler the better.
So I want to find a way to design the database. For example, my database has five tables with note fields, so I think we can put all the notes of these five tables into one table, and my design can be like this:
The c_id, c_table1id, c_table2id, c_table3id, c_tabl4id, c_table5id, and c_comment fields in t_comment are the IDs of the table records, used to distinguish the table and record of the remarks.
For example, if I only use basic information in table 1 instead of remarks, I can directly use the following:
Select * From t_table1
To add remarks:
Select t_table. *, t_comment.c_comment from t_table1, t_comment where t_table1.t_id = t_comment.t_table1id
This is because there are few notes to be used, and the latter is almost unnecessary compared to the previous SQL statement. In a system, if there are some tables, its remarks are indispensable, and not every record will have remarks. This method can save a lot of SQL statements.CodeAnd saves a lot of resources.
In this way, the management and operation will be much better, and on average, the SQL statement writing will be much better ..... I decided to do this.
Of course, it is also a good practice to change the remarks field to the ID in the remarks table in each table, this depends on the Usage Frequency of the remarks to determine which method to use.
ArticleSource: http://computer.mblogger.cn/wucountry/posts/49781.aspx