473,545 Members | 2,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Lookup field vs junction table

I am working on an electronic flashcard program. Most of the subjects
are simple lists of questions and answers. Those seem to be working.

Some of the "subjects" have "categories " of questions.

One example is a kind of trivia subject. There are several
"categories " such as "geography" , "history", etc., like in the Trivial
Pursuit game. Each card has a question in each category.

Since the categories really don't factor into the question other than
being a title, my plan was to define a lookup field in the table for
the categories:

Field Data Type Description
QuestionID Long (4) Primary key. Autonum.
Category Lookup Trivia categories.
Question Memo The trivia question.
Answer Memo The answer.

Is that a reasonable table design for this application?

A second example involves a more complicated use of categories. It's a
database about various information about the 50 US states. For each
state, I neeed to store information about the capitol city, the date
it was admitted to the union, the size, etc.

For this application, I think I need two tables (States and
Categories) with a junction table to effect a many-to-many
relationship:

tblStates:

Field Data Type Description
StateID Long (4) Primary key. Autonum.
State Text (20) Name of the state.

tblCategories:

Field Data Type Description
CatID Long (4) Primary key. Autonum.
CatTitle Text (20) Name of the state.
CatQuestion Memo The question.

tblAnswer

Field Data Type Description
StateID Long (4) Link to tblStates.
CatID Long (4) Link to tblCategories.
Answer Memo The answer.

Here's some sample data:

tblStates:

StateID State
1 Alabama
2 Alaska
3 Arizona

tblCategories:

CatID State Question
1 Capitol City What is the capitol city?
2 Date Admitted When was the state admitted to the Union?

tblAnswers:

StateID CatID Answer
1 1 Montgomery
1 2 December 14, 1819
2 1 Juneau
2 2 January 3, 1959
3 1 Phoenix
3 2 February 14, 1912

Is this a good database design for this application?

Thanks

--
Running MS Office 2000 Pro on Win2000
Jul 12 '06 #1
1 3624
LurfysMa wrote:
Since the categories really don't factor into the question other than
being a title, my plan was to define a lookup field in the table for
the categories:

Field Data Type Description
QuestionID Long (4) Primary key. Autonum.
Category Lookup Trivia categories.
Question Memo The trivia question.
Answer Memo The answer.

Is that a reasonable table design for this application?
>...
For this application, I think I need two tables (States and
Categories) with a junction table to effect a many-to-many
relationship:

tblStates:

Field Data Type Description
StateID Long (4) Primary key. Autonum.
State Text (20) Name of the state.

tblCategories:

Field Data Type Description
CatID Long (4) Primary key. Autonum.
CatTitle Text (20) Name of the state.
CatQuestion Memo The question.

tblAnswer

Field Data Type Description
StateID Long (4) Link to tblStates.
CatID Long (4) Link to tblCategories.
Answer Memo The answer.
Murfy's La',

Don't use a lookup field to edit the data directly from the table -- at
least not until Access 2007 :-). Use a form to edit the questions
using a combobox to get the possible categories.

For your states example, it depends on how you're going to use the
data. For example, are you going to show the user their overall score
when they're done? A separate tblAnswers might be easier to compute
this. I haven't actually tried storing the answers both ways, nor have
I tried to compare the resulting SQL statements for that calculation.
I suggest that you actually do that comparison to see which schema
works best for your initial uses of the database. Also, are you
limiting yourself to general questions that can be asked of any state?
It looks like you are forcing each question to have a general category.
How would a question like "In what year was the Alamo constructed?" fit
into a category? I still have not thought much on what a great schema
would be for trivia or survey questions. I used to work for a company
that composed, administered and analyzed surveys for business marketing
so an ideal schema for that purpose would be one that allows me to
create, edit, administer and analyze surveys easily. I would want to
have a schema that allows for as many kinds of question formats as
possible as early as possible since a new question format seems likely
to be the first hurdle thrown (!) at a trivia or survey schema. What
you have seems normalized enough. So if it is allowing you to drill
questions and to get the feedback you need I would say that your schema
is adequate for now, but try to anticipate likely future requirements
if possible.

As far as which of the schemata you have shown have the most merit,
your observation that the Category can be modelled as a kind of
optional attribute to a question seems much more flexible and useful.
In your case the Category/CID is only used as a means to group
questions. Of course, if you plan to break down the answer percentages
by category also you would have to look at the resulting SQL again to
see if something like "GROUP BY CID" will work easily. Don't force a
Category junction table. You're likely to need a many-to-many soon
enough anyway.

One thing you don't show is your table for storing a particular
"survey." For Trivial Pursuit, it's not that important to keep a
history of responses. For a survey, it is. You also need a way to
determine if an answer is correct. Is "Statue of Liberty" going to be
marked as incorrect if the correct answer is "The Statue of Liberty?"
If you use a Memo field you may also need to hire a grader :-). For
your personal training you can answer the question, click a command
button to show the answer, then decide for yourself if 'X gets the
square,' bzzzzt... wrong game. The first schema needs one ID to look
up the correct answer and the second needs two ID's to look up the
correct answer so there's not that much difference in looking up an
answer (perhaps by using DLookup).

You've got to take your best guess at a schema, write the SQL you'll
need to get what you'll want, then fine tune the schema until the SQL
you need is as simple as you can make it. A lot of this is an art, but
it's not unfocused.

Finally, to make it really effective you need to hook up a relay to the
serial port. You decide for yourself how many volts to use when you
get an answer incorrect. That'll add a bit of pizzazz to your study
efforts.

Happy pursuits,

James A. Fortune
CD********@Fort uneJames.com

Jul 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4044
by: mksql | last post by:
As an example, I am building an authentication mechanisim that will use data in the 3 left tables to determine rights to objects in a destination table, diagrammed below. In this structure, multiple records in the left tables will point to multiple records in the right table. Normally, I would approach this problem using junction tables...
1
3731
by: Rene Crespo | last post by:
Hello, Sorry about the length of this explanation! I am using Access 2000 to assist an export sales department keep track of its weekly offers of products to clients. The database already keeps track of "product offers" and prepares a report that a group of Clients can receive by email or fax each week. The challenge is that not all...
3
2909
by: my-wings | last post by:
I've been reading about how evil Lookup fields in tables are, but I've got to be missing something really basic. I know this subject has been covered before, because I've just spent an hour or two reading about it on google, but there is something I still don't understand, and I'm hoping someone will be willing to explain it to me in small...
1
3344
by: Zachary Turner | last post by:
I want to make a Lookup Field based on another Lookup field. In other words, I have this table A with two fields: ID and Name, where ID is an Autonumber and Name is a friendly name. Then I have a table B which links to A via a Lookup Field so that I can select the friendly name from combo box. Now, I want to have a table C which links to...
3
10616
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems that are hard to find. The main problem I am having right now is that I have a report that is sorted by one of these lookup fields and it only displays...
1
1890
by: Paul H | last post by:
Say I have a table called tblPeopleInfo, one of the fields in the table is called FavouriteFruit. The FavouriteFruit field is a lookup field and will contain Apples, Oranges, Grapes etc..The list can be added to by users of the database. What is the best way to construct this lookup? Should it lookup a Table/Query or a Value List? If it...
2
3146
by: Khers | last post by:
OK, I'm pretty new to access and I have this (maybe simple) question I have to tables Employee Computer employees has a employee autonumber as primary key adn Computer has a serialnr. as the primary key I have a many-to-many relationship between these table with another
11
2632
by: Paul H | last post by:
Suppose I have a table called tblPeople and I want a field to illustrate whether each person prefers cats or dogs. I could do it one of three ways. 1. A plain text field Create a text field in tblPeople called PreferredPet. 2. A lookup field that stores text values. Create a text field in tblPeople called PreferredPetID and use it to...
2
1801
by: kandroski | last post by:
On 2/11/08 (Post #3), ADezii helped Robert Johnson with a many-to-many table question. I have the same question - I have a table called audiovisual item (VHS tapes or DVDs - similar to a book). An audiovisual item can have multiple performers (similar to authors), and a performer can be connected with multiple audiovisual items. I created a...
0
7661
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7815
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7763
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5976
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4949
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1891
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1020
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
712
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.