1

I have a database table named order. It contains eCommerce orders. Problem is, that's a reserved word in MySQL, and while I can use back-ticks to prevent issues, it's probably a good idea not to use a reserved word.

I could name it orders. Problem is, that's a plural. The rest of my tables using the singular naming scheme. Also, there's some debate on using plurals for database table names, and most people seem to prefer using singular.

I could name it order_details, which is technically correct because each row contains details, as opposed to order_items where each row contains an item, but it's rather confusing.

I think naming things is hard, but also important. Order tables are very common and I hope this question, while specific, will be useful to future users.

What should I rename my order table?

  • I used the table name "users" with PostgreSQL; I think the reason was that "user" was a reserved word. I didn't see any problem with it being plural and others being singular. – juhist Jul 28 '17 at 15:06
  • 3
    I'd call it 'orders' because it contains orders. – GrandmasterB Jul 28 '17 at 15:12
  • 1
    @GrandmasterB, strangely enough, that is quite convincing. – Goose Jul 28 '17 at 15:16
  • Avoiding reserved word clashes and the pure logical niceness of it are two very good reasons to favour plural names for tables. The only con I can see - that it makes using automatic code generators and ORM tools a bit harder to configure - really doesn't seem anywhere near as important to me. Go plural. Change all your tables if you can easily update all the clients. – Jules Jul 28 '17 at 16:45
  • I like OrderThatIsNotThatOrder... – Barry Franklin Jul 28 '17 at 18:01
1

Totally opinion based, but I'll throw in a couple of ideas.

I like order_header plus order_details which makes it clear how they fit together.

You could call it sales_order to distinguish between, say, a purchase_order, which is entirely different. Or customer_order which makes it clear where the order came from.

Or you could keep the name order but use the database's syntax to distinguish it from a keyword. In SQL Server you'd use [order] and in MySQL you'd use backticks, like this:

SELECT * FROM `order`
| improve this answer | |
0

Try specifying the type of order that it is, rather than trying to get cute with the names. Even if order was not a reserved word, this might come in handy in the future.

Consider:

  • customer_order
  • ecommerce_order
| improve this answer | |
0

Always avoid reserved keywords , consider dboorder, surely it is a database table I'd call it as dbo(database object (table_name) ie; dboorder or dbo_order

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.