Tables

G

Guest

I'm new to this... how do I construct a Categories table which would contain
all my items in an Items table? How would I assign a primary key, if any? I
have my categories identified, 9 or 10 or so... and these categories would
contain unlimitied Items over several years. Stuck...
 
L

Larry Linson

stevenericcson said:
I'm new to this... how do I construct a Categories table which would
contain
all my items in an Items table? How would I assign a primary key, if any?
I
have my categories identified, 9 or 10 or so... and these categories would
contain unlimitied Items over several years. Stuck...

The key word is "relationship".

If each item is only in one category, then you have a one-to-many
relationship from Categories to Items. You implement that by including a
"foreign key" field in the Item that refers to the Category to which that
Item belongs. You'll find this illustrated in the Northwind Traders sample
database that comes with, and installs with, Access (unless you go to some
lengths to prevent it). There's a world of good examples in Northwind.

If an item may be in multiple Categories, then you have a many-to-many
relationship between the two tables, which Access doesn't handle directly.
The way to implement that is to have a table called a "junction" or
"intersection" table, each record of which has foreign keys to both the Item
and Category tables.

Queries are your friend in handling one-to-many and many-to-many
relationshops. You put both tables in, drag from the key to the foreign key,
click the Join line to highlight it, right-click and choose "Join Type" to
select the type of join you want.

Larry Linson
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top