Hello.
Looking at the OJS version 3.3.0-8 database, I noticed that the same name (file_id) was used as the primary-key for 4 different tables (files,issue_files,library_files,temporary_files ). Also, still all these tables still use AUTO_INCREMENT.
Although the literature usually suggests using different names, if OJS had a database with a relationship between the tables, where there is a foreign key, this would not be a problem. But this is not what happens, because the tables were not connected.
The result of this is that it generates a great difficulty to understand the relationships between the database tables, isn’t it ?
Please, someone can explain what happened in the project ?
OJS started before foreign key declarations were reliably available in the database systems it supports (primarily very old versions of MySQL, but also related to the ADODB library we used to use for database abstraction). Now that we require a newer MySQL and have replaced ADODB’s schema management with Laravel’s toolset, we are actively adding FOREIGN KEY declarations for the forthcoming 3.4.0 release. Because of the number of these, it’ll probably take us another release or two to get them all in place.
If you have a specific question about the schema, I can probably answer it here.
Regards,
Alec Smecher
Public Knowledge Project Team
Hi @asmecher , thank you so much for the quick reply. =)
“If you have a specific question about the schema, I can probably answer it here.” R: In OJS version 3214, can you say how can I discover wich tables uses the file_id from ‘submission_files’ ?
(I’m trying it for removing orphaned ‘submission_files’. I’m trying to upgrade to version 3308 and it’s disturbing)
In OJS 3.3.0-8, submission_files.file_id should not be AUTO_INCREMENT, it’s a FOREIGN KEY referencing files.file_id.
The other tables you mentioned earlier (e.g. temporary_files, library_files, issue_files) have their own file_id primary keys, and they are not related to submission_files or files.
Regards,
Alec Smecher
Public Knowledge Project Team
At a glance, those tables look fine. The submission_files.submission_file_id column is auto_increment as it should be. (The submission_files.file_id column is a foreign key to files.file_id.)
Regards,
Alec Smecher
Public Knowledge Project Team