September 25, 2008 at 9:08 am
I have 2 tables:
1."Employee" which has 20 odd fields.
2."User" has 80 odd fields.
When a record is inserted in Employee table a trigger in this table will insert a record in User Table with 20 odd values that Employee has,plus the other 60 odd values to the remaining columns in User table based on a value in a column in Employee Table which can take 5 different values.
The values for 60 odd fields in user needs to be hard coded in the trigger.
My question is simple, which is the best way to do this? So as to minimize coding and so that the execution of this trigger does not slow down the system.
September 25, 2008 at 9:46 am
nithin
This appears to be a rather under normalized design and my first suggestion would be to look at your design. The other 60 odd values if as you state will be hard coded, these can be placed in a "lookup" table and the employee table linked to the "lookup" table and there will be no need for a trigger, and the addition of a employee would require an insert into a single table, making for the simpliest coding and most rapid transaction.
September 25, 2008 at 11:03 am
I know off course its a bad design. But there are some issues because,these tables are part of an Enterprise SW, its actually CRM and because of this and other issues I have to have 2 Tables.Please trust me I need two tables so what is the best way to solve this? Do I need to update the user record like
Insert into User (select All_columns from employee)
if(flag_value=1)
Update user
set(40 odd columns....)
else if(flag_value=2)
update user
set(40 odd values..)
etc...
where uers_id = somevalue
So my question is there better way to insert all the values
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply