I
I
Ilya2020-04-17 06:39:30
MySQL
Ilya, 2020-04-17 06:39:30

How to create a relationship between two tables in the database when one field refers to several fields?

Two tables:

  1. Types
  2. Kinds


One species can belong to several types.
How to implement it in the database?

Create a list field with the id of the views in the types or are there smarter ways?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2020-04-17
@Rsa97

If one view can be associated with several types, and each type can be associated with only one view, then the one-to-many relationship is implemented by the view_id field in the type table.
If one view can be associated with several types, and one type with several types, then this is many-to-many and is built on an intermediate link table (view_id, type_id).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question