Showing posts with label area. Show all posts
Showing posts with label area. Show all posts

Tuesday, March 27, 2012

Creating/Normalizing a database

Sorry if this is the incorrect area to ask this question [for my solution].
I'm NOT a SQL programmer but a pretty good layman.
I'd like to create a test database. I've been wondering if my thinking is
correct in normalizing it.
Table Questions
QID [pk]
QText
Table Answers
AnsID [pk]
QID [fk]
Ans
Table CorrectAnswers
AnsID [pk]
QID [fk]
-- OR --
One [flat] table for it all. Obviously there will be nulls here, especially
for T/F.
Table Test
QID [pk]
QText
Answer0
Answer1
Answer2
Answer3
Answer4
Answer5
Answer6
Answer7
Answer8
Answer9
AnswerCorrect (should this contain the text of the correct answer or the
Field Name of the correct answer?)
Now... I have 100 questions and want to extract 25% randomly. I need a
randomizer for a for loop to not ONLY randomize the questions, but randomize
the non T/F answers if it is multiple choice. (which begs a question, should
I have a field that specifies it as a T/F [Yes/No] answer or multiple
choice?)
What would my SQL statement look like?
Anybody who can answer this will ultimately write my entire logic for my
task and I thank you.
Jon| I'd like to create a test database. I've been wondering if my thinking is
| correct in normalizing it.
|
| Table Questions
| QID [pk]
| QText
|
| Table Answers
| AnsID [pk]
| QID [fk]
| Ans
|
| Table CorrectAnswers
| AnsID [pk]
| QID [fk]
|
| -- OR --
| One [flat] table for it all. Obviously there will be nulls here,
especially
| for T/F.
|
| Table Test
| QID [pk]
| QText
| Answer0
| Answer1
| Answer2
| Answer3
| Answer4
| Answer5
| Answer6
| Answer7
| Answer8
| Answer9
| AnswerCorrect (should this contain the text of the correct answer or the
| Field Name of the correct answer?)
|
| Now... I have 100 questions and want to extract 25% randomly. I need a
| randomizer for a for loop to not ONLY randomize the questions, but
randomize
| the non T/F answers if it is multiple choice. (which begs a question,
should
| I have a field that specifies it as a T/F [Yes/No] answer or multiple
| choice?)
|
| What would my SQL statement look like?
|
| Anybody who can answer this will ultimately write my entire logic for my
| task and I thank you.
--
Hi Jon,
If you have one and only one correct answer for each question, then I would
design your tables as follows:
Tbl_Questions
Question_no (primary key)
Question_Text
Question_CorrectAnswer
Tbl_PossibleAnswers
Question_no (foreign key)
PossibleAnswer_no
PossibleAnswer_Description
There will be a one-to-many relationship between tbl_Questions and
tbl_PossibleAnswers.
Hope this helps,
--
Eric Cárdenas
SQL Server support

Friday, February 17, 2012

creating diagrams from SQL Scripts

Hi,

i'm in the modeling area of the portuguese post, and i've a doubt.

i've scripts of some DB (that i've exported from SQL Server) that i want to register im my default SQL (local). But when i run the script of creating the DB on my machine, it doesn't create the diagrams.

Is there any way that i've got this ?

thanks,

Jo?o P.

The diagrams are data stored in system tables so they wouldn't be included in the script of the database.

If you have access to the original database, there are some ways to move/import the diagrams but how you do this depends on what version of SQL Server. If you want to do that, please post back the version of SQL Server (is it SQL Server 7.0, 2000, 2005, etc)

-

|||

Thanks,

my version of SQL is 2000.

cheers,

Jo?o Pedro

|||

This article explains how to move diagrams on SQL 2000:

How To Move a Database Diagram

http://support.microsoft.com/kb/320125

-Sue

|||

thanks for the help,

cheers,

jo?o Pedro