I recently wondered about the more efficient linking of tables in a database. For example:
First way
| tasks | |----------------------------| | id INT | // primary key | title VARCHAR(20) | // index field | description VARCHAR (2000) | | test_data | |----------------------------| | id INT | // primary key | id_task INT | // foreign key | input_data VARCHAR (200) | | output_data VARCHAR (200) | Second way
| tasks | |----------------------------| | title VARCHAR(20) | // primary key | description VARCHAR (2000) | | test_data | |----------------------------| | id INT | // primary key | title_task VARCHAR(20) | // foreign key | input_data VARCHAR (200) | | output_data VARCHAR (200) | In this example, two tables are shown (tasks and test data for tasks). I wanted to finally understand the issue of binding, because in some books I saw that the binding was the first way, i.e. through additional id fields. In other training materials I found that the link goes directly to the field containing any information. In this regard, I would like to get a clear answer to the topic when it is better to use what and how, and why? I would also like to use the opinion about the id field in each table, how important is it? Thank you in advance...