Link to home
Start Free TrialLog in
Avatar of ezkhan
ezkhanFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Storing Data From Front End Page to SQL Server. What is the best approach??????????

Hi,

I have a situation where I am passing lots of data from frontend page to the SQL Server using variable type tables.

My question is should I pass actual character values as selected by users from dropdowns or check boxes to the backend to store into normalized database after using lookups to find their ids and store them into tables
OR
Should I find the Id values beforehand for the string values selected from the dropdowns or for the radio buttons and pass these Ids to store into SQL Server tables.

-----------

During the first insert of the record it adds record to Master tables so it has to populate master table then populate child tables.

Which approach is better?

Your comments and suggestions are appreciated.

Thanks.
Avatar of Jason Yousef
Jason Yousef
Flag of United States of America image

usually what's in the drop down and being displayed is the native key or the description, but you store the key for it.

So I'd go with the second one, you also need to check whichever is easier to maintain, troubleshoot and faster.
Avatar of nilesh31
nilesh31

You should store ID as VALUE and string as TEXT in dropdown and radio button.
So whenever page is submitted directly pass dropdown and  radio button Value to SQL Server  which will contain the ID .
Avatar of ezkhan

ASKER

Hi,

Thanks for your valuable comments. I have the same feeling to use IDs from the front end to pass to the back end.

1---
But, imagine a situation where a record is going to be inserted first time in master table and then subsequent child tables. And IDs for the master records are not known. I need to pass master record string values from textboxes (Sorry forgot to mention it before). Once these are stored then I'll store child records as per the master Ids.

2---
In the meanwhile there are number of titles shown on front end are already populated in the back end master tables. Now, I am passing these titles and selected values from drop downs against these titles as character strings to stored procedure using Table Value Parameters. Once, received in stored procedure I join TableValueParameter table to master table on character values to find out their IDs and then use then use these master IDs to store record in child tables.

You can imagine the kind of situation it is now. For the 1st situation where master ids are not know I have to pass character strings to back end stored procedure to create master record. Can you please suggest is this the valid approach or is there any other option available to do it and I am not aware of it.


And for 2nd situation where master records are stored and Ids can be extracted to store in data in child tables. The approach I am using is capturing all character string values from the front end (And instead of quering database tables to find Ids of these strings  I am) storing them in a sort of denormalized TableValueParameter type table and passing it to stored procedure. Where I am joining received string values to master tables to find out their IDs

For Example.
From front end I am passing

insert into @TVP (ClientName, PortionName, SubPortionName,PortionVisibility,SubPortionVisibility,
G1Permission,G2Permission,G3Permission)
Values ('ExpertExchange','Databases','SQL Server',1,1,1,0,1)

.
.
.
.
.

Now after receiving these values in stored procedure to find out Ids;

I join
ClientName with ClientName in ClientTable and get its id and I do the same for to get all other master ids.
Once I have Ids for
ClientName,PortionName,SubPortionName I use them to store in GroupPermission tables.

Hope I have explained the my question in detail. Now what I want to know is my approach valid?

I really appreciate the time and effort you put in to read my question. Waiting for your valuable comments and suggestions.


Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Ted Bouskill
Ted Bouskill
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ezkhan

ASKER

good