I have a scenario of saving user details into my database(MySQL 5.1); i have three tables for saving user details; user_data
,user_contact
,user_address
, so if i insert one user data i have to check for existence of data in these tables. i have different functions for checking and procedures for insert into separate tables, So that i can use them separately and together depends on needs/situations.
insertion requires the following steps:
- check of existence of data/s in user_data if exist skip the insertion, if not insert details.
- check of existence of data/s in user_contact if exist skip the insertion and update
contact_gid
in user table, if not insert details and updatecontact_gid
in user table. - similar in the case of user_address.
Here my question is that,
Which method is more efficient?
-
calling each separate procedure/function from my .net application,
check for condition and call the next based on the condition using a
single transaction. -
Pass all required parameters(for all functions) to a single procedure,
the condition checking and further executions are handled within this
procedure.