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 |
|
edi843
Starting Member
12 Posts |
Posted - 2009-04-17 : 05:51:23
|
| Hi everybody,I have a big decision to take. I am constructing a database where I will have a table for the sales. Each row, of this table, belongs to a specified company and to a specified year. Let say i will have a table where i will store the companies and a table where i will store the years. I have two alternatives :1. In the table of sales, i store the id of company and the id of the year.2. I construct a third table, where i store the id of the year, the id of the company, and a new id called new_id(uniqe in this table). And in the table of sales i store only the newid.Any idea ?!Thanks in advance |
|
|
theboyholty
Posting Yak Master
226 Posts |
Posted - 2009-04-17 : 06:49:11
|
| Normalisation is generally the best way to go (i.e. having references to data in another table) but don't do it just for the sake of doing it.If your references to the company name is your first table will be the ONLY reference to that company name, there's no point in doing it. If you're going to have multiple rows for the same company in your table then yes, you need to store that data in a separate table.As for your years, I can't think of a reason why you'd need to reference that in a separate table it'll only make the data harder to read and probably won't be of any benefit.Thats my opinion, I hope I haven't just started a new argument. |
 |
|
|
edi843
Starting Member
12 Posts |
Posted - 2009-04-17 : 08:51:56
|
| Maybe, i was not so clear in what i asked. What i really want to know is if in the table of Sales is better to store two fields( the id of the company, and the id of the year(may be the year itself)) or is better to store only one id that identifies in unique manner the company and the year which this record belongs. ?? |
 |
|
|
whitefang
Enterprise-Level Plonker Who's Not Wrong
272 Posts |
Posted - 2009-04-17 : 08:56:54
|
| It makes NO sense to normalize the YEAR field in a sales table. It makes sense to normalize the company field in the sales table (the company is a "data lookup field", makes sense to normalize). |
 |
|
|
|
|
|
|
|