[Stackoverflow good question] the SQL table name should use the plural or singular number, stackoverflowsql

Source: Internet
Author: User

[Stackoverflow good question] the SQL table name should use the plural or singular number, stackoverflowsql
ProblemThe SQL table name should be in the plural or singular form of the resource object corresponding to the table. For example, if a user table is named "user" or "users", is it more appropriate?
Excellent answer
The singular form is better, for the following reasons:
1. Intuitive Concept.You have a bag with many apples in it. You will say this is an Apple bag. However, whether there are 0, 1, or 1 million apples in it, it is still a bag. The same is true for tables, indicating that you need to clearly describe the objects in the table, rather than the number of data records.
2. ConvenienceThe singular form is simpler. There are some words. the plural form may be unconventional, or there is no plural form, but the singular form is different. The plural of some words may think of your big head, but google may have to make it happen.
3. EleganceIn particular, some resource names in the form of master-detail are uniformly used in the singular form, which makes it easier to read, align more neatly, and make the order more logical. Comparison singular:

  • Order
  • OrderDetail
Plural:
  • OrderDetails
  • Orders

4. SimplicityImagine that you can use a single number regardless of the table name, primary key, link, and instance Classes. all seem so uniform, and you don't have to worry about changing your thinking in a variety of singular numbers.
  • Customer
  • Customer. CustomerID
  • CustomerAddress
  • Public Class Customer {...}
  • Select from Customer WHERE CustomerID = 100
Once you confirm that the object to be processed is named "Customer", all database-Related interactions and programming will use this word.
5. GlobalizationSuppose you are in a global team. Some of the members are not in English. It is more difficult for them to recognize and write the plural form of a word, it also brings trouble to the team.
6. Why notThis can save your spelling time, hard disk space, and even make your keyboard "longer"
  • SELECT Customer. CustomerName FROM Customer WHERE Customer. CustomerID = 100
  • SELECT Customers. CustomerName FROM Customers WHERE Customers. CustomerID = 100
Based on these two statements, you can save 3 letters, 3 bytes, and 3 mouse clicks.
Finally, I also think that you should add a prefix to some conflicting names, such as User, to add the corresponding prefix, that is, User> LoginUser, AppUser, SystemUser, CMSUser ,...
Stackoverflow link: http://stackoverflow.com/questions/338156/table-naming-dilemma-singular-vs-plural-names

Column introduction: I like stackoverflow very much and can always find a solution to the problem. The website has a popularity list. So I selected some hot questions and sorted out the discussion based on my own understanding. Therefore, these articles are not really translated, but have made some additions, deletions, and retouching based on your own understanding. I hope that the above discussions can be shared with you more concisely and effectively. If you need to reprint, please specify the original addressHttp://blog.csdn.net/lizeyang

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.