If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Need guidance

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-26-09, 20:58
pritishz pritishz is offline
Registered User
 
Join Date: Oct 2009
Location: Richardson
Posts: 3
Question Need guidance

Hi All,

I have some concern regarding the ER Diagram. I have the following scenario: We need to keep all the information regarding the agent like Name, Address, Phone No and also his monthly salary, commission paid. Now I have created an entity Agent and defined attributes which are necessary and required.

My question is should I have a separate entity for maintaining the Agents Salary ? The reason why I am asking is like, the salary may change sometime say the agent might get an increment. Now because of that, if the agent salary is kept in the Agent Entity and I need to update the whole table when there is increase in the salary of the agent. I guess it is not a good practice to fire a query to update a single Attribute. Also if I have 100K records it will take a lot of time to update.

From the knowledge I have it is always good to have a separate Table for the attribute whose values keeps changing in my case it is "Salary".

So can you suggest me which is the correct way .. Keeping all attributes in one table or having a separate table when we have such scenario ?

I will really appreciate your reply and guidance.
Reply With Quote
  #2 (permalink)  
Old 10-26-09, 21:19
MarkATrombley MarkATrombley is offline
Registered User
 
Join Date: Jul 2009
Location: Michigan
Posts: 125
A person's name, address, and phone number can change too. Just because something might change isn't a reason to put it into its own table.

If agents of a certain type all get the same salary and that salary will go up for all of the agents of that type then you would want to put salary into a table with agent type and add type to the agent table. Otherwise leave the salary in the agent table.
Reply With Quote
  #3 (permalink)  
Old 10-26-09, 21:25
pritishz pritishz is offline
Registered User
 
Join Date: Oct 2009
Location: Richardson
Posts: 3
Question

I agree to your point. But, say all the agents have different salary and at the end of every three month they get an increment then should I have a separate table for that ?
Reply With Quote
  #4 (permalink)  
Old 10-26-09, 21:48
MarkATrombley MarkATrombley is offline
Registered User
 
Join Date: Jul 2009
Location: Michigan
Posts: 125
Leave the salary in the agent table. Breaking the salary out won't help because you still have to update the same number of records (however many changed) and the same number of columns (one). The machine and programmer effort to do the update will be the same either way.
Reply With Quote
  #5 (permalink)  
Old 10-27-09, 00:59
AnanthaP AnanthaP is offline
Registered User
 
Join Date: May 2009
Location: India
Posts: 62
However, if the salary is left in the agents table and the agent gets a new value (which is upddated), then you will not be able to see the old value.

I expect that it's largely a matter of knowing the end user requiements.

If you need to see and apply history data, then you need to spin off salary into a separate table with another column called effective data. Further, only one attribute may change.

End
Reply With Quote
  #6 (permalink)  
Old 10-27-09, 02:35
pritishz pritishz is offline
Registered User
 
Join Date: Oct 2009
Location: Richardson
Posts: 3
Question

@ AnanthaP

Hello Sir,

I really appreciate your reply. So you mean if for an attribute we need to store historical information we should always have an separate table for that entity right ?

in what other information do I need to make a separate entity for an attribute ??

Thanks for your time and consideration
Reply With Quote
  #7 (permalink)  
Old 10-27-09, 03:20
AnanthaP AnanthaP is offline
Registered User
 
Join Date: May 2009
Location: India
Posts: 62
Repeating groups ,

Data dependant on part of the primary key only,

Data not dependant on the primary key alone.

End
Reply With Quote
  #8 (permalink)  
Old 10-27-09, 04:13
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,246
If you need the history of an entity of its attribute then you need to devise a mechanism to appropriately store that entity/attribute. how you implement that is up to you

separate entity/separate table rarely makes sense, there are occasions when it does make sense but they are rare.

I could see some value is say recording an agents commission over time becuase it will vary period by period, it may be of interest, but not salaray
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On