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.
Author |
Topic |
BlasterOfMuppets
Starting Member
8 Posts |
Posted - 2008-02-14 : 17:10:45
|
Is there a good way to name tables that are used as lookup tables? If you have a table for movies and you think that a movie can be in more than one genre. Then you will have tables like the following.a table for movies, table 1id name ...1 Scarfacea table for the movie genres, table 2id name ...1 action2 mafiaa table that links the genres to the movies, table 3id table 1 id table 2 id1 1 1 2 1 2Table 1 is no problem. I name it movie. Table 2 is the genres. I name it movie_genres.Table 3 specifies the genres for a specific movie so I name it movie_genres. Duh, already taken. This is just an example and perhaps not the best. What should I call my to genre tables? |
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2008-02-14 : 17:17:21
|
Unless a movie is going to be in more than one genre add gener_id to the movies table.Else name your table movies_x_movie_genres IE a cross reference between the 2"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
 |
|
BlasterOfMuppets
Starting Member
8 Posts |
Posted - 2008-02-14 : 17:45:06
|
Thank you!I believe it's a bit hard to read when I use it with joins but I can live with that. |
 |
|
SusanthaB
Starting Member
14 Posts |
Posted - 2008-02-15 : 00:25:45
|
For lookup tables use the suffix as Lkup. E.g. Movie_LkupTable 2 you can name as Genres, and 3rd table name as Movie_To_Gengres or Movie_GengresSusantha BathigeSenior DBA, Sri Lanka |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
BlasterOfMuppets
Starting Member
8 Posts |
Posted - 2008-02-15 : 13:21:37
|
quote: Originally posted by SusanthaB For lookup tables use the suffix as Lkup. E.g. Movie_LkupTable 2 you can name as Genres, and 3rd table name as Movie_To_Gengres or Movie_GengresSusantha BathigeSenior DBA, Sri Lanka
I need to think about the postfix. If I name the table genre then I have problem if i add a music table. In programming you would solve it with namespaces or equilient. Can I do the same in SQL? |
 |
|
BlasterOfMuppets
Starting Member
8 Posts |
Posted - 2008-02-15 : 13:23:24
|
quote: Originally posted by madhivanan Also refer http://vyaskn.tripod.com/object_naming.htmMadhivananFailing to plan is Planning to fail
I disagree with most of the naming suggestions in that reference. |
 |
|
|
|
|