Watch out, learning sql newbie. I would like to create 2 simple tables.
products: id | product_name
order_table: id | buyer_name | purchased_products
CREATE TABLE products (
id INTEGER PRIMARY KEY,
product_name TEXT
);
CREATE TABLE order_table (
id INTEGER PRIMARY KEY,
buyer_name TEXT,
purchased_products NUMERIC ARRAY
);
Currently the link is numeric, but this would require the report generation to know that purchased_products is referring to the products table. Is it possible to define that the purchased_products must be referring to the products?
Note: this is sqlite3,
Remove the field
purchased_productsand create one more table, like this:order_product: id | order_id | product_id
Now, you should declare that
order_idis a foreign key referring to the fieldidof the tableorder_table, and that product_id does the same forproducts.