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 |
|
Exir
Posting Yak Master
151 Posts |
Posted - 2009-09-08 : 05:37:10
|
| HiWhich one is better from bellow?Having one table like this:ID/NAME/JoBID/COUNTRYID/LANGUAGEID----------------------------------1/Tom/teacher/USA/English2/John/driver/Saudi/ArabicOr more tables with relations like this: ID/NAME/JoBID/COUNTRYID/LANGUAGEID----------------------------------1/Tom/1/2/22/John/4/5/3LANGUAGENAME/LANGUAGEID-----------------------Franch/1English/2Arabic/3COUNTRY/COUNTRYID-----------------France/1USA/2UK/3Italy/4Saudi/5India/6JOB/JOBID----------teacher/1tailor/2butcher/3driver/4When should we use id instead of name?Andanother question:when i want to desplay my table how should i do it? i want the fields be shown by their names not ID. Thanks for your help |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-08 : 05:45:10
|
Relations!select p.Name,l.Languagename,c.Country,j.Jobfrom persons pjoin languages l on l.languageid = p.languageidjoin countries c on c.countryid = p.countryidjoin jobs j on j.jobid = p.jobid No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Exir
Posting Yak Master
151 Posts |
Posted - 2009-09-09 : 03:09:21
|
| Thank you very much.but i dont know when one table should be used and when more tables with relations between them (as in example) ?please enlighten it for me |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-09-09 : 04:55:13
|
use separate table when you have more than one attribute. Example for the Country, you can have other attribute like Capital, National Language, Area, Population etc.Read more about Normalization. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|