G
G
gimade2017-02-20 16:33:12
MySQL
gimade, 2017-02-20 16:33:12

How to add a foreign key relationship?

We have 3 empty tables: make(id, name), model(id, name), make_model(make_id, model_id)
Data: Car brand, models of this brand
Purpose: Add a brand, models of this brand and establish links by ID in the 3rd table.
Question: How to do it right?
I just started working with databases, I have little experience, so the first thought that came to my mind was to add a brand, model to the database, then request the ID of the brand, model that were added and write down the connection in the 3rd plate. Is this ok, or are there other easier ways? Maybe I made the database schema wrong?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question