0

I got these 3 tables

Ques Table

 Ques |Ans          |QuesID|LangID
__________________________________________
Ques1|Ques1's Answer|1     |1
Ques2|Ques2's Answer|2     |2

LangID is a Foreign Key that References LangID in table Languages

Languages Table

LangID         |Description|LanguageID
______________________________________
1              |French     |1
2              |English    |2

Language Table is for website's contents' language

EditorLanguage table

LanguageID|Value|Desc
______________________
1         |fr-FR|French
2         |en-US|English US

EditorLanguage Table is for RadEditor's Language

When a new Ques is added:-

The InsertUpdateQues Stored Procedure inserts the following values in Ques Table:-

QuesID, Ques, Ans, LangID

Now on my Ques Page, I have the following:-

-A drop down list box to select language (this drop down is bound to EditorLanguage Table's Desc column)
-A Text Box for Ques
-Telerik RadEditor for Ques's Answer
- Submit cancel buttons

Now lets say the langauage selected from the drop down is French whose language ID=1, Value=fr-FR, desc=French

Now how do I pass this LangID value to InsertUpdateQues Stored proceedure. I mean how it should get this value?

I am confused because of this Foreign Key thing..new too ms sql

How will the logic be formed? What is even going on here ? so ok it will get LangID somehow but how and what good will that do ? I am suddenly feeling lost.

1
  • My mistake. I thought you were asking about how to pass the value to the SP. Commented Dec 7, 2010 at 19:09

1 Answer 1

1

Why are Languages and EditorLanguage separate tables? Based on what you're showing us, it looks like they would be better as a single table. The table names and key names are unintuitive as well.

As it stands right now, you're going to have to translate the LanguageID that the form is posting into a LangID that the Ques table needs. This can be done in code by hitting the database (or a cached lookup) to select LangID from Languages where LanguageID equals the value you have. Or you can do this inside of the stored procedure you're calling (so it's only a single trip to the database) by either selecting the value into a variable and using the variable in your insert/update, or by using a subquery in your insert/update to select the value.

Note that this may get clouded if there's any kind of one-to-many relationship between Languages and EditorLanguage.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.