Sql – Is it bad practice to ‘go backwards’ with a foreign key

sql

I was wondering if it is bad practice to have a file_table { id, name, status} and a extra_data table { id, fileId FK(file.id), otherData}. So far all my tables go forward and I never needed to get the id of one table then do a query to get more data using an id.

Is this bad practice and if so then why?

Best Answer

This is perfectly fine. Your table designed as laid out, establishes that one file_table record can be associated with 0 or more extra_data records. However, one extra_data record can only be associated to one file_table record.

What do you mean by going backwards?