r/DatabaseHelp • u/AcceleratedCode • Nov 18 '15
Managing data with multiple relations
Hi!
I'm new to MySQL and databases in general, and I'm currently setting up a sample database where you have (atm) a table with customers, and a table with orders. I hvae a primary key called customer_id in the customers table, and a primary key called order_id in the orders table. I also have a foreign key in the orders table that refers to the customer_id in the customers table.
Here's an image of my diagram
But what I don't understand is how to manage the data in these tables.
I suppose you'd do a INSERT INTO customers VALUES (1, "test", "test")
But how do you "connect" these to the other tables? How can a key in the customers table refer to another table in the query?
Thanks! Erik
UPDATE
I've changed my model to include a new table to allow for multiple products per order.
View all comments
Show parent comment
1
u/AcceleratedCode Nov 19 '15
Thanks! Please take a look at my update, how does it look now?