I'm a beginner and mentally wrestling with a many-to-many relationship.
I have an IT equipment inventory database. The main table is All Equipment, and two lookup tables that it currently references are Manufacturer (where the choices for the Manufacturer field in the main table come from) and Item Type (where the choices for Item Type come from).
When a new piece of equipment is being entered into the database I want the Item Type to narrow down the list of items available in the Manufacturers lookup.
On the Manufacturers table I created a Item Type field which allows multiple choices. When you create a new Manufacturer, you simply tick which Item Types they produce in the Item Type field. The choices for that field come of course from Item Types table.
As a first step I then tried to create a criteria which reduces the options available under Manufacturer when entering a new items of equipment to the database. I started by trying to specify the Item Type myself within the criteria. So I tried to create a criteria that basically said "offer this manufacturer in the lookup list if the Item Types field within the Manufacturers table includes the value "Projectors". Put another way I wanted the criteria to look down the Manufacturers listed in the Manufacturers table and say for each one: 'does this manufactuer include "Projector" in the Item Type field'.
But I ran into a big snag. Obviously within the Manufacturers table, Item Types is a muli-value field. For example Benq produce both Monitors and Projectors, so their entry in the Item Type field is "Monitor, Projector". But Access refuses to run SQL criteria including the WHERE or HAVING operators on a Multivalue field. In fact going into the query builder wizard and double clicking on the Manufacturers table I could only select the Manufacturers ID, or name. The Item Type field wasn't listed presumably because it was Multi Value.
I don't understand why I couldn't build something based on LIKE to treat the multivalue field as a string and effectively say "YES (or TRUE) that string contains the value "Projectors", or "NO (or FALSE) that string does not contain "Projectors". But I couldn't do it because my SQL syntax understanding is absolutely hopeless. Yes I have googled, but the context of people's explanations is wrong, or I don't understand what they are saying, or how to adapt it, because of my lack of SQL. I am very keen to learn more about how to build and use SQL statements, but will need a little help before the learning process takes off.
It has occurred to me that Item Types and Manufacturers have a many-to-many relationship. All Item Types are produced by many Manufacturers, and several Manufacturers produce more than one Item Type. I've read instructions on the internet that tell you to use a linking table with each field referenced via the others foreign key.
However this is a theoretical explanation, and I don't understand it in practice. a) That is the structure of the linking table, but what data would fill it? Edit: the only thing I can think of is that it would contain:
ItemType1 NameofManufacturer1
ItemType1 NameofManufacturer2
ItemType1 NameofManufacturer3
ItemType1 NameofManufacturer4
ItemType2 NameofManufacturer5
ItemType3 NameofManufacturer2
ItemType3 NameofManufacturer4
ItemType4 NameofManufacturer6
But I maybe wrong and anyway what a tedious way of linking data.
b) Having established this many-to-many relationship, how would it help me with my attempt to narrow down Manufacturer based on Item Type? Would it help me at all?
I have an IT equipment inventory database. The main table is All Equipment, and two lookup tables that it currently references are Manufacturer (where the choices for the Manufacturer field in the main table come from) and Item Type (where the choices for Item Type come from).
When a new piece of equipment is being entered into the database I want the Item Type to narrow down the list of items available in the Manufacturers lookup.
On the Manufacturers table I created a Item Type field which allows multiple choices. When you create a new Manufacturer, you simply tick which Item Types they produce in the Item Type field. The choices for that field come of course from Item Types table.
As a first step I then tried to create a criteria which reduces the options available under Manufacturer when entering a new items of equipment to the database. I started by trying to specify the Item Type myself within the criteria. So I tried to create a criteria that basically said "offer this manufacturer in the lookup list if the Item Types field within the Manufacturers table includes the value "Projectors". Put another way I wanted the criteria to look down the Manufacturers listed in the Manufacturers table and say for each one: 'does this manufactuer include "Projector" in the Item Type field'.
But I ran into a big snag. Obviously within the Manufacturers table, Item Types is a muli-value field. For example Benq produce both Monitors and Projectors, so their entry in the Item Type field is "Monitor, Projector". But Access refuses to run SQL criteria including the WHERE or HAVING operators on a Multivalue field. In fact going into the query builder wizard and double clicking on the Manufacturers table I could only select the Manufacturers ID, or name. The Item Type field wasn't listed presumably because it was Multi Value.
I don't understand why I couldn't build something based on LIKE to treat the multivalue field as a string and effectively say "YES (or TRUE) that string contains the value "Projectors", or "NO (or FALSE) that string does not contain "Projectors". But I couldn't do it because my SQL syntax understanding is absolutely hopeless. Yes I have googled, but the context of people's explanations is wrong, or I don't understand what they are saying, or how to adapt it, because of my lack of SQL. I am very keen to learn more about how to build and use SQL statements, but will need a little help before the learning process takes off.
It has occurred to me that Item Types and Manufacturers have a many-to-many relationship. All Item Types are produced by many Manufacturers, and several Manufacturers produce more than one Item Type. I've read instructions on the internet that tell you to use a linking table with each field referenced via the others foreign key.
However this is a theoretical explanation, and I don't understand it in practice. a) That is the structure of the linking table, but what data would fill it? Edit: the only thing I can think of is that it would contain:
ItemType1 NameofManufacturer1
ItemType1 NameofManufacturer2
ItemType1 NameofManufacturer3
ItemType1 NameofManufacturer4
ItemType2 NameofManufacturer5
ItemType3 NameofManufacturer2
ItemType3 NameofManufacturer4
ItemType4 NameofManufacturer6
But I maybe wrong and anyway what a tedious way of linking data.
b) Having established this many-to-many relationship, how would it help me with my attempt to narrow down Manufacturer based on Item Type? Would it help me at all?
Last edited: