# Table naming question

**URL:** <https://www.ruby-forum.com/t/table-naming-question/188362>\
**Category:** Rails\
**Created:** [May 10, 2010, 10:54pm UTC](https://www.ruby-forum.com/t/table-naming-question/188362 "2010-05-10T22:54:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@matthew](https://www.ruby-forum.com/u/matthew)\
**Post date:** [May 10, 2010, 10:54pm UTC](https://www.ruby-forum.com/t/table-naming-question/188362/1 "2010-05-10T22:54:55Z")

</div>

Conisdering the naming conventions of ActiveRecord tables…

I have a parent table called “Jobs” and a child table to it called  
“JobItems” which holds the line items on any give “Job” that we process.

Now I’m dealing with the Invoice table, which is a Parent-type of table  
(“Invoices”), and I have an “InvoiceItems” child that is related to it.

However, in some ways, each Invoice is also a child record to a Job.  
(Some Jobs build up multiple Invoices if we do progress billing of  
partial shipments).

So, one could argue that the “Invoices” table should be named  
“JobInvoices”, and the child invoice items would go in a table name  
“JobInvoiceItems”.

So…

Invoices and InvoiceItems

or

JobInvoices and JobInvoiceItems

Which way is the accepted way?

---

<div class="post-metadata">

**Author:** ![matthew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@matthew](https://www.ruby-forum.com/u/matthew)\
**Post date:** [May 10, 2010, 11:06pm UTC](https://www.ruby-forum.com/t/table-naming-question/188362/2 "2010-05-10T23:06:07Z")

</div>

On 10 May 2010 21:54, Matt S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> partial shipments).
> 
> So, one could argue that the “Invoices” table should be named  
> “JobInvoices”, and the child invoice items would go in a table name  
> “JobInvoiceItems”.

I would consider the language that the client (or yourself) uses when  
talking about the objects in the tables. For example if you talk  
about job invoices then that should be the name of the table. If you  
just call them invoices then that should be it. The objects in the  
system should map to real world objects in as intuitive a way as  
possible. That way you may hope to minimise confusion.

Colin
