NibblyPig
NibblyPig

Reputation: 52952

What's the standard practice for naming an intermediary table in SQL?

I have a table called Product and a table called Shop. Each shop has a list of Products that it sells. I need an intermediate table that has ShopID and ProductID in it. What should I call that table? My mind has drawn a blank.

ShopProducts?

Edit: Perhaps I should call it "ShopAvailableProducts"? Or is that too confusing.

Upvotes: 5

Views: 1458

Answers (6)

Touten
Touten

Reputation: 298

I have seen product_shop_rel used by ORMs. Like in OERP (now known as Odoo) for example.

Upvotes: 0

SQLDev
SQLDev

Reputation: 206

Shop2Product (or Product2Shop) is better: "2" in mid shows that this is intermediary table.

Upvotes: -1

Preet Sangha
Preet Sangha

Reputation: 65556

Personally I would just use ShopProduct as it makes sense in my language a product for/from/asociated-with a shop.

Upvotes: 0

vodkhang
vodkhang

Reputation: 18741

Yes, ShopProducts is good enough. No problem with that

Upvotes: 0

Anton Gogolev
Anton Gogolev

Reputation: 115857

I prefer something along the lines of ShopProductsJunction. This article might give a few other naming hints:

...also known as a cross-reference table, bridge table, join table, map table, intersection table, linking table, or link table

Upvotes: 2

amelvin
amelvin

Reputation: 9061

Yes ShopProduct (depending on the plurals you use) would be how I'd name a link entity.

Shop
  |
-----
| | |
ShopProduct
| | |
-----
  |
Product

So a shop can have many products and each product can be sold in many shops

Upvotes: 9

Related Questions