How would I design the tables for a matching system doing something like this:
We have X products which can have Y properties. The number of properties can vary from product to product and two products doesn't have to have any similar properties.
My number one goal is to take one product and find the most similar product.
Normally I would do something like this
create table products
(
id serial not null primary key,
name varchar(40)
)
create table properties
(
id serial not null primary key,
name varchar(40)
)
create table product_properties
(
product_id int not null,
property_id int not null
)
The only way I can think of is to loop through all products, fetch their properties in the loop and compare with the source product. But that doesn't seem very effective.