Is the Chinese field name written in the table or in the file? Solution
Source: Internet
Author: User
Is the Chinese field name written in the table or in the file? During database program development, we encounter many problems, one of which is that the English name of the field is compared with the Chinese name. For example, the Username in the database must be mapped to a "user name". This "user name" must be used to query users, authorize users, and so on when users are added and users are edited, therefore, if we can write him somewhere, we can use scaffolding to directly read this name from the field's Chinese name in the table or in the file?
During database program development, we encounter many problems, one of which is that the English name of the field is compared with the Chinese name.
For example, the Username in the database must be mapped to a "user name". This "user name" must be used to query users, authorize users, and so on when users are added and users are edited, therefore, if we can write him somewhere, we can use scaffolding to read the name directly and display the title.
Now, the question is, where can I write this reference file?
The advantage of writing in a table is to reduce file IO, and the table structure is better than that of loose files.
The advantage of writing in a file is to reduce the number of database reads. The disadvantage is that it is hard to write and easy to write errors. Especially when processing multi-dimensional arrays. Also, if you change these structures during design.
I have read some frameworks, most of which are written in files and saved as an array. these frameworks, of course, consider that our web designers may not have the permission to change the database structure. However, most programmers in China can easily move to the database structure.
Let's vote. if you are designing, where would you choose to put it?
------ Solution --------------------
Chinese field name ?! Why don't you use the i18n method directly?
------ Solution --------------------
We recommend that you write it directly in the table and field comments so that you can get it in information_schema. 'columns.
You can read or write a code segment each time. after changing the table design, you can output comments to the file at a time.
------ Solution --------------------
It is recommended to store the memory table. check it if necessary.
Or table join query, or direct query
When there are many users, table operations are much faster
When there are few users, file operations are faster
------ Solution --------------------
Refer to the MVC framework,
Write to class files.
Object-oriented database access
------ Solution --------------------
We generally write files.
------ Solution --------------------
Discussion
Chinese field name ?! Why don't you use the i18n method directly?
------ Solution --------------------
Write in comments!
------ Solution --------------------
We are also in class files ~~~ There are also table comments
Recommend the former
------ Solution --------------------
Usually written in table/field comments
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service