Very quick questions, as a matter of best pratice, do you name your database tables singluar or plural?
Cheers,
Stephen
-
-
singular, plural just feels weird
-
harumscarum wrote:singular, plural just feels weird
seconded.
the few times I did plural-names I regreted it ....
Staff
Order
OrderDetail
SomethingLog
its the "RowName"
Table of Orders has rows that are each an "Order"
would you want to see:
Select *
from Order
Where Order.ID = 1234
or
Select *
from Orders
Where Orders.ID = 1234
the "Where" shows how the naming starts to work or not work I think; Order.ID reads much nicer than Orders.ID I think.
the from could go ither way...
-
Singular
-
PerfectPhase wrote:Very quick questions, as a matter of best pratice, do you name your database tables singluar or plural?
Cheers,
Stephen
We had a thread about this a few years ago.
Anyway, I'm a plural man myself.
-
Plural too. It's a set of things.
-
W3bbo wrote:We had a thread about this a few years ago.
Let's recycle that old thread, hehe.
Isn't this weird:
-- update 1 contact
UPDATE Contact SET
FirstName = @FirstName,
LastName = @LastName,
Email = @Email
WHERE Key = @ContactKey
You specify one contact but need to give it a key to make sure it is that contact...
-
Plural..
-
Why not provide both? Just name your table singular and add a plural synonym, like this:
CREATE TABLE [Person] (...) CREATE SYNONYM [People] FOR [Person]
Then you can use either, whichever makes more sense:UPDATE [Person] SET ... WHERE [ID]=@id DELETE [People] WHERE [Age] < @minAge
-
TommyCarlier wrote:Why not provide both? Just name your table singular and add a plural synonym, like this:
CREATE TABLE [Person] (...) CREATE SYNONYM [People] FOR [Person]
Then you can use either, whichever makes more sense:UPDATE [Person] SET ... WHERE [ID]=@id DELETE [People] WHERE [Age] < @minAge
Aliases are bad though, and not every DBMS supports synonyms.
-
Why are they bad?
-
And about DBMSes that don't support synonyms: you could create a view instead of a synonym. CREATE VIEW [People] AS SELECT * FROM [Person]
-
TommyCarlier wrote:Why not provide both? Just name your table singular and add a plural synonym
I think this can be very confusing. Between freedom of choice and explicitness of meaning, I'd got for the latter every time. -
littleguru wrote:Plural too. It's a set of things.
I've always used plural up to now, I think that 'SELECT * FROM Orders WHERE where OrderId = ... ' reads better than the singluar version as the table is a set of data.
But I've been tinkering with the Entity Framework and the designer just seems to work better with tables named in the singular, so it just got me wondering, and then there was the table called 'Series' the other day...
-
Plural is the safest in my opinion. I actually feel pretty strongly about this in our designs because most reserved words are singular (e.g. ORDER, USER, etc). While most T-SQL interfaces are smart enough to put "[]" around the word to make it correct, its just safer and allows for less confusion with clear statements.
-
PerfectPhase wrote:But I've been tinkering with the Entity Framework and the designer just seems to work better with tables named in the singular, so it just got me wondering, and then there was the table called 'Series' the other day...
What do you call an indexed table which stores information about Sheep then?
-
W3bbo wrote:
What do you call an indexed table which stores information about Sheep then?
Indeed
-
Sheeps, duh!
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.