Click here to Skip to main content
15,898,893 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!

I'am developing an application for IQ test in c# win form, my qoustion in the test some are with image and some are with text, and i need when i take the test the question to come random from database, I start to create a table in sql but i dont know becouse one column can be image one colomn can be a text?


Can somebody hepl me?


Thnx
Posted

For this you need to create three tables the first one will be LookUp table with information of what type of data you are storing against that record.

And the second table will be a ValueLookUp where you will be storing the actual value of the record with a Foreign Key reference of the LookUp table.

And the third one will be a ImageLookUp table where you will store images against the record of the LookUp table.

In the LookUp table if you record is Value Type then you can its value from ValueLookUp table using the Foreign Key reference. And if it is an Image Type you can get the image from ImageLookUp table using the Foreign Key of LookUp table.

Hope this helps, tell me if I got you wrong.
 
Share this answer
 
v2
Without seeing your database structure, I cannot speak very specifically, but what I would do would be to either split out the questions from their data (so one table would contain a list of all of the questions and then they would link either to the image table or the text table) or I would include both columns in the one table (text and image). If I did the second, it would be simpler but it would leave a lot of null columns (which can be ok).

In the second scenario, you would simply pick a random row, then test the text area to see if it is null (or the picture field). If it is null, choose the other one to display. If it isn't, display that field.

In the first example, you would need to do a second lookup based upon the specified type (a column saying text or image) into the second table (either the text table or the image table).
 
Share this answer
 
Hi.

So, according to your question there is some unclear moment.
Why do you need one column, which can contains differ data types ?)
Maybe it would be more resonable to create table with 2 columns(for appropriate data types text/image) which can contains NULL. In future when you try to populate test data, you goes through records and check for null some of column, and depend from return type null or smth else you create appropriate representation for that.

But also, i think it's possible to implement one column DB design.
Let assume, that you will create column whith BLOB data type and call it Data. Then you just populate data for test whith binary data representation.
For data retrieving, you will need to implemet validation stage and by that result populate your UI.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900