<p>Whenever I design a database, I always wonder if there is a best way of naming an item in my database. Quite often I ask myself the following questions:</p>

<ol>
<li>Should table names be plural?</li>
<li>Should column names be singular?</li>
<li>Should I prefix tables or columns?</li>
<li>Should I use any case in naming items?</li>
</ol>

<p>Are there any recommended guidelines out there for naming items in a database?</p>

[{'answer_id': 7663, 'author': 'Lars Mæhlum', 'author_id': 960, 'author_profile': 'https://Stackoverflow.com/users/960', 'pm_score': 6, 'selected': False, 'text': '<ol>\n<li>No. A table should be named after the entity it represents.\nPerson, not persons is how you would refer to whoever one of the records represents.</li>\n<li>Again, same thing. The column FirstName really should not be called FirstNames. It all depends on what you want to represent with the column.</li>\n<li>NO.</li>\n<li>Yes. Case it for clarity. If you need to have columns like "FirstName", casing will make it easier to read.</li>\n</ol>\n\n<p>Ok. Thats my $0.02</p>\n'}, {'answer_id': 7667, 'author': 'Matt Hamilton', 'author_id': 615, 'author_profile': 'https://Stackoverflow.com/users/615', 'pm_score': 7, 'selected': False, 'text': '<p>Ok, since we\'re weighing in with opinion:</p>\n\n<p>I believe that table names should be plural. Tables are a collection (a table) of entities. Each row represents a single entity, and the table represents the collection. So I would call a table of Person entities People (or Persons, whatever takes your fancy).</p>\n\n<p>For those who like to see singular "entity names" in queries, that\'s what I would use table aliases for:</p>\n\n<pre><code>SELECT person.Name\nFROM People person\n</code></pre>\n\n<p>A bit like LINQ\'s "from person in people select person.Name".</p>\n\n<p>As for 2, 3 and 4, I agree with @Lars.</p>\n'}, {'answer_id': 7672, 'author': 'Mario Marinato', 'author_id': 431, 'author_profile': 'https://Stackoverflow.com/users/431', 'pm_score': 4, 'selected': False, 'text': "<p>I think the best answer to each of those questions would be given by you and your team.  It's far more important to have a naming convention then how exactly the naming convention is.</p>\n\n<p>As there's no right answer to that, you should take some time (but not too much) and choose your own conventions and - <em>here's</em> the important part - stick to it.</p>\n\n<p>Of course it's good to seek some information about standards on that, which is what you're asking, but don't get anxious or worried about the number of different answers you might get:  choose the one that seems better for you.</p>\n\n<p>Just in case, here are my answers:</p>\n\n<ol>\n<li>Yes.  A table is a group of <em>records</em>, <em>teachers</em> or <em>actors</em>, so... plural.</li>\n<li>Yes.</li>\n<li>I don't use them.</li>\n<li>The database I use more often - Firebird - keeps everything in upper case, so it doesn't matter.  Anyway, when I'm programming I write the names in a way that it's easier to read, like <em>releaseYear</em>.</li>\n</ol>\n"}, {'answer_id': 7677, 'author': 'Bell', 'author_id': 977, 'author_profile': 'https://Stackoverflow.com/users/977', 'pm_score': 4, 'selected': False, 'text': '<ol>\n<li>Definitely keep table names singular, person not people\n\n<ol start="2">\n<li>Same here</li>\n<li>No. I\'ve seen some terrible prefixes, going so far as to state what were dealing with is a table (tbl_) or a user store procedure (usp_). This followed by the database name... Don\'t do it! </li>\n<li>Yes. I tend to PascalCase all my table names</li>\n</ol></li>\n</ol>\n'}, {'answer_id': 7678, 'author': 'Keith', 'author_id': 905, 'author_profile': 'https://Stackoverflow.com/users/905', 'pm_score': 4, 'selected': False, 'text': "<p>My opinions on these are:</p>\n\n<p>1) No, table names should be singular.</p>\n\n<p>While it appears to make sense for the simple selection (<code>select * from Orders</code>) it makes less sense for the OO equivalent (<code>Orders x = new Orders</code>).</p>\n\n<p>A table in a DB is really the set of that entity, it makes more sense once you're using set-logic:</p>\n\n<pre><code>select Orders.*\nfrom Orders inner join Products\n    on Orders.Key = Products.Key\n</code></pre>\n\n<p>That last line, the actual logic of the join, looks confusing with plural table names.</p>\n\n<p>I'm not sure about always using an alias (as Matt suggests) clears that up.</p>\n\n<p>2) They should be singular as they only hold 1 property</p>\n\n<p>3) Never, if the column name is ambiguous (as above where they both have a column called [Key]) the name of the table (or its alias) can distinguish them well enough. You want queries to be quick to type and simple - prefixes add unnecessary complexity.</p>\n\n<p>4) Whatever you want, I'd suggest CapitalCase</p>\n\n<p>I don't think there's one set of absolute guidelines on any of these.  </p>\n\n<p>As long as whatever you pick is consistent across the application or DB I don't think it really matters.</p>\n"}, {'answer_id': 7687, 'author': 'Lord Future', 'author_id': 978, 'author_profile': 'https://Stackoverflow.com/users/978', 'pm_score': -1, 'selected': False, 'text': '<pre><code>\n--Example SQL\n\nCREATE TABLE D001_Students\n(\n    StudentID INTEGER CONSTRAINT nnD001_STID NOT NULL,\n    ChristianName NVARCHAR(255) CONSTRAINT nnD001_CHNA NOT NULL,\n    Surname NVARCHAR(255) CONSTRAINT nnD001_SURN NOT NULL,\n    CONSTRAINT pkD001 PRIMARY KEY(StudentID)\n);\n\nCREATE INDEX idxD001_STID on D001_Students;\n\nCREATE TABLE D002_Classes\n(\n    ClassID INTEGER CONSTRAINT nnD002_CLID NOT NULL,\n    StudentID INTEGER CONSTRAINT nnD002_STID NOT NULL,\n    ClassName NVARCHAR(255) CONSTRAINT nnD002_CLNA NOT NULL,\n    CONSTRAINT pkD001 PRIMARY KEY(ClassID, StudentID),\n    CONSTRAINT fkD001_STID FOREIGN KEY(StudentID) \n        REFERENCES D001_Students(StudentID)\n);\n\nCREATE INDEX idxD002_CLID on D002_Classes;\n\nCREATE VIEW V001_StudentClasses\n(\n    SELECT\n        D001.ChristianName,\n        D001.Surname,\n        D002.ClassName\n    FROM\n        D001_Students D001\n            INNER JOIN\n        D002_Classes D002\n            ON\n        D001.StudentID = D002.StudentID\n);\n</code></pre>\n\n<p>These are the conventions I was taught, but you should adapt to whatever you developement hose uses.</p>\n\n<ol>\n<li>Plural. It is a collection of entities.</li>\n<li>Yes. The attribute is a representation of singular property of an entity.</li>\n<li>Yes, prefix table name allows easily trackable naming of all constraints indexes and table aliases.</li>\n<li>Pascal Case for table and column names, prefix + ALL caps for indexes and constraints.</li>\n</ol>\n'}, {'answer_id': 7714, 'author': 'Guy', 'author_id': 993, 'author_profile': 'https://Stackoverflow.com/users/993', 'pm_score': 6, 'selected': False, 'text': '<p>I work in a database support team with three DBAs and our considered options are:</p>\n\n<ol>\n<li>Any naming standard is better than no standard.</li>\n<li>There is no "one true" standard, we all have our preferences</li>\n<li>If there is standard already in place, use it. Don\'t create another standard or muddy the existing standards.</li>\n</ol>\n\n<p>We use singular names for tables.  Tables tend to be prefixed with the name of the system (or its acronym).  This is useful if the system complex as you can change the prefix to group the tables together logically (ie. reg_customer, reg_booking and regadmin_limits).</p>\n\n<p>For fields we\'d expect field names to be include the prefix/acryonm of the table (i.e. cust_address1) and we also prefer the use of a standard set of suffixes ( _id for the PK, _cd for "code", _nm for "name", _nb for "number", _dt for "Date").</p>\n\n<p>The name of the Foriegn key field should be the same as the Primary key field.  </p>\n\n<p>i.e. </p>\n\n<pre><code>SELECT cust_nm, cust_add1, booking_dt\nFROM reg_customer\nINNER JOIN reg_booking\nON reg_customer.cust_id = reg_booking.cust_id\n</code></pre>\n\n<p>When developing a new project, I\'d recommend you write out all the preferred entity names, prefixes and acronyms and give this document to your developers.  Then, when they decide to create a new table, they can refer to the document rather than "guess" what the table and fields should be called.</p>\n'}, {'answer_id': 7715, 'author': 'winsql', 'author_id': 605, 'author_profile': 'https://Stackoverflow.com/users/605', 'pm_score': 3, 'selected': False, 'text': '<p>Naming conventions allow the development team to design discovereability and maintainability at the heart of the project. </p>\n\n<p>A good naming convention takes time to evolve but once it’s in place it allows the team to move forward with a common language. A good naming convention grows organically with the project. A good naming convention easily copes with changes during the longest and most important phase of the software lifecycle - service management in production.</p>\n\n<p>Here are my answers:</p>\n\n<ol>\n<li>Yes, table names should be plural when they refer to a set of <em>trades</em>, <em>securities</em>, or <em>counterparties</em> for example.</li>\n<li>Yes.</li>\n<li>Yes. SQL tables are prefixed with tb_, views are prefixed vw_, stored procedures are prefixed usp_ and triggers are prefixed tg_ followed by the database name.</li>\n<li>Column name should be lower case separated by underscore. </li>\n</ol>\n\n<p>Naming is hard but in every organisation there is someone who can name things and in every software team there should be someone who takes responsibility for namings standards and ensures that naming issues like <em>sec_id</em>, <em>sec_value</em> and <em>security_id</em> get resolved early before they get baked into the project.</p>\n\n<p>So what are the basic tenets of a good naming convention and standards: -</p>\n\n<ul>\n<li>Use the language of your client and\nyour solution domain</li>\n<li>Be descriptive</li>\n<li>Be consistent</li>\n<li>Disambiguate, reflect and refactor</li>\n<li>Don’t use abbreviations unless they\nare clear to everyone</li>\n<li>Don’t use SQL reserved keywords as\ncolumn names</li>\n</ul>\n'}, {'answer_id': 7724, 'author': 'urini', 'author_id': 373, 'author_profile': 'https://Stackoverflow.com/users/373', 'pm_score': 10, 'selected': True, 'text': '<p>I recommend checking out Microsoft\'s SQL Server sample databases:\n<a href="https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks" rel="noreferrer">https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks</a></p>\n\n<p>The AdventureWorks sample uses a very clear and consistent naming convention that uses schema names for the organization of database objects.</p>\n\n<ol>\n<li>Singular names for tables</li>\n<li>Singular names for columns</li>\n<li>Schema name for tables prefix (E.g.: SchemeName.TableName)</li>\n<li>Pascal casing (a.k.a. upper camel case)</li>\n</ol>\n'}, {'answer_id': 7764, 'author': 'SQLMenace', 'author_id': 740, 'author_profile': 'https://Stackoverflow.com/users/740', 'pm_score': 5, 'selected': False, 'text': '<p>Take a look at ISO 11179-5: Naming and identification principles\nYou can get it here: <a href="http://metadata-standards.org/11179/#11179-5" rel="noreferrer">http://metadata-standards.org/11179/#11179-5</a></p>\n\n<p>I blogged about it a while back here: <a href="http://sqlservercode.blogspot.com/2006/11/iso-11179-naming-conventions.html" rel="noreferrer">ISO-11179 Naming Conventions</a> </p>\n'}, {'answer_id': 7858, 'author': 'Thomas Owens', 'author_id': 572, 'author_profile': 'https://Stackoverflow.com/users/572', 'pm_score': 4, 'selected': False, 'text': '<p>In my opinion:</p>\n\n<ol>\n<li>Table names should be plural.</li>\n<li>Column names should be singular.</li>\n<li>No.</li>\n<li>Either CamelCase (my preferred) or underscore_separated for both table names and column names.</li>\n</ol>\n\n<p>However, like it has been mentioned, any convention is better than no convention. No matter how you choose to do it, document it so that future modifications follow the same conventions.</p>\n'}, {'answer_id': 226710, 'author': 'Chris', 'author_id': 21388, 'author_profile': 'https://Stackoverflow.com/users/21388', 'pm_score': 3, 'selected': False, 'text': '<p>Here\'s a link that offers a few choices.  I was searching for a simple spec I could follow rather than having to rely on a partially defined one.</p>\n\n<p><a href="http://justinsomnia.org/writings/naming_conventions.html" rel="noreferrer">http://justinsomnia.org/writings/naming_conventions.html</a></p>\n'}, {'answer_id': 229288, 'author': 'onedaywhen', 'author_id': 15354, 'author_profile': 'https://Stackoverflow.com/users/15354', 'pm_score': 5, 'selected': False, 'text': '<p>I\'m also in favour of a ISO/IEC 11179 style naming convention, noting they are guidelines rather than being prescriptive.</p>\n\n<p>See <a href="http://en.wikipedia.org/wiki/Data_element_name" rel="noreferrer">Data element name on Wikipedia</a>:</p>\n\n<p>"Tables are Collections of Entities, and follow Collection naming guidelines. Ideally, a collective name is used: eg., Personnel. Plural is also correct: Employees. Incorrect names include: Employee, tblEmployee, and EmployeeTable."</p>\n\n<p>As always, there are exceptions to rules e.g. a table which always has exactly one row may be better with a singular name e.g. a config table. And consistency is of utmost importance: check whether you shop has a convention and, if so, follow it; if you don\'t like it then do a business case to have it changed rather than being the lone ranger.</p>\n'}, {'answer_id': 2118567, 'author': 'Patrick Karcher', 'author_id': 97890, 'author_profile': 'https://Stackoverflow.com/users/97890', 'pm_score': 8, 'selected': False, 'text': '<p>Late answer here, but in short:</p>\n<ol>\n<li><strong>Plural table names:</strong> My <em>preference</em> is plural</li>\n<li><strong>Singular column names:</strong> Yes</li>\n<li><strong>Prefix tables or columns:</strong></li>\n</ol>\n<ul>\n<li><em>Tables</em>: *Usually* no prefixes is best.</li>\n<li><em>Columns</em>: No.</li>\n</ul>\n<ol start="4">\n<li><strong>Use any case in naming items:</strong> PascalCase for both tables and columns.</li>\n</ol>\n<p>Elaboration:</p>\n<p>(1) <em><strong>What you must do.</strong></em>  There are very few things that you <em>must</em> do a certain way, every time, but there are a few.</p>\n<ul>\n<li>Name your <strong>primary keys</strong> using &quot;[singularOfTableName]ID&quot; format.  That is, whether your table name is <em>Customer</em> or <em>Customers</em>, the primary key should be <em>CustomerID</em>.</li>\n<li>Further, <strong>foreign keys <em>must</em> be named consistently</strong> in different tables.  It should be legal to beat up someone who does not do this.  I would submit that while defined foreign key constraints are <em>often</em> important, consistent foreign key naming is <em>always</em> important</li>\n<li>You database must have <strong>internal conventions</strong>.  Even though in later sections you\'ll see me being very flexible, <em>within</em> a database naming must be very consistent .  Whether your table for customers is called <em>Customers</em> or <em>Customer</em> is less important than that you do it the same way throughout the same database.  And you can flip a coin to determine how to use underscores, but then you <em>must keep using them the same way</em>.  If you don\'t do this, you are a bad person who should have low self-esteem.</li>\n</ul>\n<p>(2) <em><strong>What you should probably do.</strong></em></p>\n<ul>\n<li>Fields representing the same kind of data on different tables <em>should</em> be named the same.  Don\'t have Zip on one table and ZipCode on another.</li>\n<li>To separate words in your table or column names, use PascalCasing.  Using camelCasing would not be intrinsically problematic, but that\'s not the convention and it would look funny.  I\'ll address underscores in a moment.  (You may not use ALLCAPS as in the olden days.  OBNOXIOUSTABLE.ANNOYING_COLUMN was okay in DB2 20 years ago, but not now.)</li>\n<li>Don\'t artifically shorten or abbreviate words.  It is better for a name to be long and clear than short and confusing.  Ultra-short names is a holdover from darker, more savage times.  Cus_AddRef.  What on earth is that?  Custodial Addressee Reference?  Customer Additional Refund?  Custom Address Referral?</li>\n</ul>\n<p>(3) <em><strong>What you should consider.</strong></em></p>\n<ul>\n<li>I really think you should have plural names for tables; some think singular.  Read the arguments elsewhere.  Column names should be singular however.  Even if you use plural table names, tables that represent combinations of other tables might be in the singular.  For example, if you have a <em>Promotions</em> and an <em>Items</em> table, a table representing an item being a part of a promotion could be Promotions_Items, but it could also legitimately be Promotion_Items I think (reflecting the one-to-many relationship).</li>\n<li>Use underscores consistently and for a particular purpose.  Just general tables names should be clear enough with PascalCasing; you don\'t need underscores to separate words.  Save underscores either (a) to indicate an associative table or (b) for prefixing, which I\'ll address in the next bullet.</li>\n<li>Prefixing is neither good or bad.  It <em>usually</em> is not best.  In your first db or two, I would not suggest using prefixes for general thematic grouping of tables.  Tables end up not fitting your categories easily, and it can actually make it <em>harder</em> to find tables.  With experience, you can plan and apply a prefixing scheme that does more good than harm.  I worked in a db once where data tables began with <em>tbl</em>, config tables with <em>ctbl</em>, views with <em>vew</em>, proc\'s <em>sp</em>, and udf\'s <em>fn</em>, and a few others; it was meticulously, consistently applied so it worked out okay.  The only time you NEED prefixes is when you have really separate solutions that for some reason reside in the same db; prefixing them can be very helpful in grouping the tables.  Prefixing is also okay for special situations, like for temporary tables that you want to stand out.</li>\n<li>Very seldom (if ever) would you want\nto prefix columns.</li>\n</ul>\n'}, {'answer_id': 2121237, 'author': 'Ian Boyd', 'author_id': 12597, 'author_profile': 'https://Stackoverflow.com/users/12597', 'pm_score': 3, 'selected': False, 'text': '<pre><code>SELECT \n   UserID, FirstName, MiddleInitial, LastName\nFROM Users\nORDER BY LastName\n</code></pre>\n'}, {'answer_id': 2523754, 'author': 'Albert', 'author_id': 302565, 'author_profile': 'https://Stackoverflow.com/users/302565', 'pm_score': 5, 'selected': False, 'text': "<p>our preference:</p>\n\n<ol>\n<li><p>Should table names be plural?<br>\nNever. The arguments for it being a collection make sense, but you never know what the table is going to contain (0,1 or many items). Plural rules make the naming unnecessarily complicated. 1 House, 2 houses, mouse vs mice, person vs people, and we haven't even looked at any other languages.</p>\n\n<p><code>Update person set property = 'value'</code> acts on each person in the table.<br>\n<code>Select * from person where person.name = 'Greg'</code> returns a collection/rowset of person rows.</p></li>\n<li><p>Should column names be singular?<br>\nUsually, yes, except where you are breaking normalisation rules.</p></li>\n<li><p>Should I prefix tables or columns?<br>\nMostly a platform preference. We prefer to prefix columns with the table name. We don't prefix tables, but we do prefix views (v_) and  stored_procedures (sp_ or f_ (function)). That helps people who want to try to upday v_person.age which is actually a calculated field in a view (which can't be UPDATEd anyway).</p>\n\n<p>It is also a great way to avoid keyword collision (delivery.from breaks, but delivery_from does not).</p>\n\n<p>It does make the code more verbose, but often aids in readability.</p>\n\n<p><code>bob = new person()</code><br>\n<code>bob.person_name = 'Bob'</code><br>\n<code>bob.person_dob = '1958-12-21'</code><br>\n... is very readable and explicit. This can get out of hand though:</p>\n\n<p><code>customer.customer_customer_type_id</code></p>\n\n<p>indicates a relationship between customer and the customer_type table, indicates the primary key on the customer_type table (customer_type_id) and if you ever see 'customer_customer_type_id' whilst debugging a query, you know instantly where it is from (customer table).</p>\n\n<p>or where you have a M-M relationship between customer_type and customer_category (only certain types are available to certain categories)</p>\n\n<p><code>customer_category_customer_type_id</code></p>\n\n<p>... is a little (!) on the long side.</p></li>\n<li><p>Should I use any case in naming items?\nYes - lower case :),  with underscores. These are very readable and cross platform. Together with 3 above it also makes sense.</p>\n\n<p>Most of these are preferences though. - As long as you are consistent, it should be predictable for anyone that has to read it.</p></li>\n</ol>\n"}, {'answer_id': 5893346, 'author': 'AZ_', 'author_id': 185022, 'author_profile': 'https://Stackoverflow.com/users/185022', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://justinsomnia.org/2003/04/essential-database-naming-conventions-and-style/" rel="nofollow">Essential Database Naming Conventions (and Style)</a> (click here for more detailed description)</p>\n\n<p>table names\nchoose short, unambiguous names, using no more than one or two words\ndistinguish tables easily\nfacilitates the naming of unique field names as well as lookup and linking tables\ngive tables singular names, never plural (update: i still agree with the reasons given for this convention, but most people really like plural table names, so i’ve softened my stance)... follow the link above please</p>\n'}, {'answer_id': 6486145, 'author': 'paul444', 'author_id': 816441, 'author_profile': 'https://Stackoverflow.com/users/816441', 'pm_score': 2, 'selected': False, 'text': "<p>Table names singular. Let's say you were modelling a realtionship between someone and their address.\nFor example, if you are reading a datamodel would you prefer \n'each person may live at 0,1 or many address.' or\n'each people may live at 0,1 or many addresses.'\nI think its easier to pluralise address, rather than have to rephrase people as person. Plus collective nouns are quite often dissimlar to the singular version. </p>\n"}, {'answer_id': 7289746, 'author': 'Granger', 'author_id': 530545, 'author_profile': 'https://Stackoverflow.com/users/530545', 'pm_score': 4, 'selected': False, 'text': '<p>I know this is late to the game, and the question has been answered very well already, but I want to offer my opinion on #3 regarding the prefixing of column names.</p>\n\n<p><strong>All columns should be named with a prefix that is unique to the table they are defined in.</strong></p>\n\n<p>E.g. Given tables "customer" and "address", let\'s go with prefixes of "cust" and "addr", respectively. "customer" would have "cust_id", "cust_name", etc. in it. "address" would have "addr_id", "addr_cust_id" (FK back to customer), "addr_street", etc. in it.</p>\n\n<p>When I was first presented with this standard, I was dead-set against it; I hated the idea. I couldn\'t stand the idea of all that extra typing and redundancy. Now I\'ve had enough experience with it that I\'d never go back.</p>\n\n<p>The result of doing this is that all of the columns in your database schema are unique. There is one major benefit to this, which trumps all arguments against it (in my opinion, of course): </p>\n\n<p><strong>You can search your entire code base and reliably find every line of code that touches a particular column.</strong></p>\n\n<p>The benefit from #1 is incredibly huge. I can deprecate a column and know exactly what files need to be updated before the column can safely be removed from the schema. I can change the meaning of a column and know exactly what code needs to be refactored. Or I can simply tell if data from a column is even being used in a particular portion of the system. I can\'t count the number of times this has turned a potentially huge project into a simple one, nor the amount of hours we\'ve saved in development work.</p>\n\n<p>Another, relatively minor benefit to it is that you only have to use table-aliases when you do a self join:</p>\n\n<pre><code>SELECT cust_id, cust_name, addr_street, addr_city, addr_state\n    FROM customer\n        INNER JOIN address ON addr_cust_id = cust_id\n    WHERE cust_name LIKE \'J%\';\n</code></pre>\n'}, {'answer_id': 7539217, 'author': 'vishesh marwah', 'author_id': 962631, 'author_profile': 'https://Stackoverflow.com/users/962631', 'pm_score': 2, 'selected': False, 'text': '<p><strong>Table Name:</strong> It should be singular, as it is a singular entity representing a real world object and not objects, which is singlular.</p>\n\n<p><strong>Column Name:</strong> It should be singular only then it conveys that it will hold an atomic value and will confirm to the normalization theory. If however, there are n number of same type of properties, then they should be suffixed with 1, 2, ..., n, etc. </p>\n\n<p>Prefixing Tables / Columns: It is a huge topic, will discuss later.</p>\n\n<p>Casing: It should be Camel case</p>\n\n<p>My friend, <strong>Patrick Karcher</strong>, I request you to please not write anything which may be offensive to somebody, as you wrote, "•Further, foreign keys must be named consistently in different tables. It should be legal to beat up someone who does not do this.". I have never done this mistake my friend Patrick, but I am writing generally. What if they together plan to beat you for this? :)</p>\n'}, {'answer_id': 11187406, 'author': 'Annie', 'author_id': 1479656, 'author_profile': 'https://Stackoverflow.com/users/1479656', 'pm_score': 3, 'selected': False, 'text': '<p>Table names should always be singular, because they represent a set of objects. As you say herd to designate a group of sheep, or flock do designate a group of birds. No need for plural. When a table name is composition of two names and naming convention is in plural it becomes hard to know if the plural name should be the first word or second word or both.\nIt’s the logic – Object.instance, not objects.instance. Or TableName.column, not TableNames.column(s).\nMicrosoft SQL is not case sensitive, it’s easier to read table names, if upper case letters are used, to separate table or column names when they are composed of two or more names.</p>\n'}, {'answer_id': 13680105, 'author': 'janb', 'author_id': 214983, 'author_profile': 'https://Stackoverflow.com/users/214983', 'pm_score': 2, 'selected': False, 'text': "<p>Very late to the party but I still wanted to add my two cents about column prefixes</p>\n\n<p>There seem to be two main arguments for using the table_column (or tableColumn) naming standard for columns, both based on the fact that the column name itself will be unique across your whole database:</p>\n\n<p>1) You do not have to specify table names and/or column aliases in your queries all the time</p>\n\n<p>2) You can easily search your whole code for the column name</p>\n\n<p>I think both arguments are flawed. The solution for both problems without using prefixes is easy. Here's my proposal:</p>\n\n<p><strong>Always use the table name in your SQL. E.g., always use table.column instead of column.</strong></p>\n\n<p>It obviously solves 2) as you can now just search for table.column instead of table_column.  </p>\n\n<p>But I can hear you scream, how does it solve 1)? It was exactly about avoiding this. Yes, it was, but the solution was horribly flawed. Why? Well, the prefix solution boils down to:<br>\nTo avoid having to specify table.column when there's ambiguity, you name all your columns table_column!<br>\nBut this means you will from now on ALWAYS have to write the column name every time you specify a column. But if you have to do that anyways, what's the benefit over always explicitly writing table.column? Exactly, there is no benefit, it's the exact same number of characters to type.</p>\n\n<p>edit: yes, I am aware that naming the columns with the prefix enforces the correct usage whereas my approach relies on the programmers</p>\n"}, {'answer_id': 16286634, 'author': 'dallin', 'author_id': 1274625, 'author_profile': 'https://Stackoverflow.com/users/1274625', 'pm_score': 5, 'selected': False, 'text': '<p>I hear the argument all the time that whether or not a table is pluralized is all a matter of personal taste and there is no best practice.  I don\'t believe that is true, especially as a programmer as opposed to a DBA.  As far as I am aware, there are no legitimate reasons to pluralize a table name other than "It just makes sense to me because it\'s a collection of objects," while there are legitimate gains in code by having singular table names.  For example:</p>\n\n<ol>\n<li><p>It avoids bugs and mistakes caused by plural ambiguities.  Programmers aren\'t exactly known for their spelling expertise, and pluralizing some words are confusing.  For example, does the plural word end in \'es\' or just \'s\'?  Is it persons or people?  When you work on a project with large teams, this can become an issue.  For example, an instance where a team member uses the incorrect method to pluralize a table he creates.  By the time I interact with this table, it is used all over in code I don\'t have access to or would take too long to fix.  The result is I have to remember to spell the table wrong every time I use it. Something very similar to this happened to me.  The easier you can make it for every member of the team to consistently and easily use the exact, correct table names without errors or having to look up table names all the time, the better. The singular version is much easier to handle in a team environment.</p></li>\n<li><p>If you use the singular version of a table name AND prefix the primary key with the table name, you now have the advantage of easily determining a table name from a primary key or vice versa via code alone.  You can be given a variable with a table name in it, concatenate "Id" to the end, and you now have the primary key of the table via code, without having to do an additional query.  Or you can cut off "Id" from the end of a primary key to determine a table name via code.  If you use "id" without a table name for the primary key, then you cannot via code determine the table name from the primary key.  In addition, most people who pluralize table names and prefix PK columns with the table name use the singular version of the table name in the PK (for example statuses and status_id), making it impossible to do this at all.</p></li>\n<li><p>If you make table names singular, you can have them match the class names they represent.  Once again, this can simplify code and allow you to do really neat things, like instantiating a class by having nothing but the table name.  It also just makes your code more consistent, which leads to...</p></li>\n<li><p>If you make the table name singular, it makes your naming scheme consistent, organized, and easy to maintain in every location.  You know that in every instance in your code, whether it\'s in a column name, as a class name, or as the table name, it\'s the same exact name.  This allows you to do global searches to see everywhere that data is used.  When you pluralize a table name, there will be cases where you will use the singular version of that table name (the class it turns into, in the primary key).  It just makes sense to not have some instances where your data is referred to as plural and some instances singular.</p></li>\n</ol>\n\n<p>To sum it up, if you pluralize your table names you are losing all sorts of advantages in making your code smarter and easier to handle.  There may even be cases where you have to have lookup tables/arrays to convert your table names to object or local code names you could have avoided.  Singular table names, though perhaps feeling a little weird at first, offer significant advantages over pluralized names and I believe are best practice.</p>\n'}]
['https://Stackoverflow.com/questions/7662', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/383/']