
Originally Posted by
hansendl
If I understand your post correctly, it sounds like you're referring to a many-to-many relationship (i.e., each item can have multiple tags, and each tag can apply to multiple items). The "tags" you're referring to help categorize your data so you can find it later, right? For example, if my database was tracking books, I might want to tag a particular book on MS Access programming with "non-fiction," "programming," "databases," "Microsoft," etc. A couple of things you want to consider:
1. You shouldn't arbitrarily limit the number of tags for any particular record to a fixed amount. Is there a reason you used 5 tag fields? What happens if only two tags are needed? What happens when you really need 7 tags for a particular item? Also, is the order of your tags important? Does the entry in TAG_1 have more or less significance than the entry in TAG_5?
2. If there is no business reason for having exactly 5 tags, and the order of the tags makes no difference, you really need to move the item tags to a separate table and create a many-to-many relationship. To do this, first create a new table called Tags that will house nothing but the individuals tags (for all items). This table would have only one or two fields. I recommend an autonumber primary key field ("TagID") and a text field where the name of the tag is stored ("Tag"), but you could eliminate the autonumber field and just go with the text field as your primary key (if you go this route, ensure you have the Cascade Update property selected in the table relationships). You will then create a second table to link your items with their tags. I would call this table ItemTags, and it would have the following fields: ItemID (i.e., to hold primary key values from your Items table), and TagID (i.e., to hold primary key values from your Tags table). The primary key for the ItemTags table will include both ItemID and TagID.
By structuring your tables like this, your database will be able to manage any number of tags for each item, and searching will be much easier. If you're not familiar with many-to-many relationships and data table normalization, recommend you read up on it in the links provided by ItsMe.
Good luck!