Good day. There is a need to store data on different types of cars - trucks, cars, special ones. Each type of car has its own set of characteristics. I had the idea to combine common properties into one table, and put specific ones into a separate table. And the question arose - how to connect a common table and a table of specific properties. Please advise how it is more logical to implement such a scheme and link the tables, provided that new types of cars can be added.

Общий список авто auto_list +-------+-------+-------------+ |auto_id| doors | price | +-------+-------+-------------+ | 1 | 4 | 10000 | | 2 | 3 | 20000 | | 3 | 2 | 10000 | +-------+-------+-------------+ Характеристики грузовых авто cargo_details +-------+-------+-------------+ |auto_id| cargo | wheels | +-------+-------+-------------+ | 2 | 4 | 6 | +-------+-------+-------------+ Характеристики легковых авто passenger_details +-------+-------+-------------+ |auto_id|passgrs| fuel | +-------+-------+-------------+ | 1 | 4 | 92 | | 3 | 6 | 95 | +-------+-------+-------------+ 
  • one
    Tables are linked by auto_id, as you have shown. In the general table this is PK, in the specifications - FK. In order not to create tables dynamically, it is better to foresee the possible types of cars in advance. I do not think that there will be a lot of fundamentally different models. A similar scheme is used here: sql-ex.ru/help/select13.php#db_1 Yes, I do not think that the price is a characteristic of the type. This is a characteristic of the instance. - msi
  • Thank you very much for your answer. I forgot to write that the situation is fictional. In a real situation, we are talking about other objects, just wanted to simplify. I will understand, thank you again. And then a crazy business made a separate table, for communication by type, and in that table for communication kept the name of the tables with details. - Vitali Mirsky

0