Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 table name convention for related tables

Author  Topic 

sql777
Constraint Violating Yak Guru

314 Posts

Posted - 2007-11-01 : 15:26:37
Hi,

If I have 2 tables:

TableA
aID
aCount

TableB
bID
bCount

And I need to create a 3rd table that will look like:

aID
bID

What should I call this table?

I've seen:

relAB

AXB

Any other naming conventions?

Kristen
Test

22859 Posts

Posted - 2007-11-01 : 15:29:20
We add the word "LINK" to the table name.

Given a Product table, and an Image table, we would have a ProductImageLink table.

Kristen
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-11-01 : 15:31:23


EDIT: Don't you have some work to do or something?

I would usually do

TableA_TableB

This enables a many to many and guantees only 1 combination of a thing if you put an unique key on the Relationship Table

Do you need that?

If TableA can only have 1 of a thing, then the TableB key gets stored in TableA



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-11-01 : 15:34:45
"If TableA can only have 1 of a thing, then the TableB key gets stored in TableA"

Is that the right way round Brett?

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-02 : 02:51:46

http://vyaskn.tripod.com/object_naming.htm


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

arorarahul.0688
Posting Yak Master

125 Posts

Posted - 2007-11-02 : 03:36:07

i think the easy descriptive way can be

create table ab_id or a_b_id

Rahul Arora
MCA 07 Batch
NCCE Israna, Panipat
HRY, INDIA
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-11-02 : 09:00:17
quote:
Originally posted by Kristen

"If TableA can only have 1 of a thing, then the TableB key gets stored in TableA"

Is that the right way round Brett?

Kristen



Yes, 1 of a thing from tableB which is most likely a code table

Did you mean something else?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-11-02 : 09:05:20
Dunno, I just seem to be struggling with the sense of that sentence, buts it's probably just me.

TableA = Customers
TableB = Country

TableA has a column for ID (PK) and a column for CountryCode - which joins to TableB

TableB has a column for CountyCode (PK)

So TableB has one row for "USA", TableA potentially has multiple rows for CountryCode = "USA"

So I'm comfortable with "TableB key gets stored in TableA"

Just not really understanding the "If TableA can only have 1 of a thing" because in this case TableA can have lots of "USA" CountryCode values.

Sorry if I'm just being anal ...

Kristen
Go to Top of Page
   

- Advertisement -