The scenario
I have images in a database table and some of these need to be altered then re-saved(not overwriting the original) whilst providing a reference back to the original. I also save the directory path which the images are stored, if a original image is stored in dir : 1, the altered version of this exact image would be dir : 1-1.(This I am thinking has room for improvement but I am unsure of anyway of doing it(BLOB and storing within the db is out of the question).
Current model
Files
+---------+-----------+-----------+--------+
| file_id | file_name | file_hash | folder |
+---------+-----------+-----------+--------+
| 1 | bmw.png | d29djkj38 | 1 |
| 2 | bmw.jpeg | e9sljd551 | 1 |
+---------+-----------+-----------+--------+
Altered_Files
+---------+------------------+
| file_id | original_file_id |
+---------+------------------+
| 2 | 1 |
+---------+------------------+
file_id and original_file_id here are both foreign keys to Table : Files Column : file_id.
file_id is also the Primary Key
I have never used two columns as foreign keys where both reference the same one column in another table, this makes me wonder if its a incorrect design(or perhaps its not even allowed architecturally).
As for the altered images directory folder, we can generate this by joining both tables and then using contact('-') with the results.
Overall concern
I am still new to Database modelling and wondering if this design is ok(won't need refactoring at a later date as the pros say(Edgar Codd, C Date)), perhaps it can be improved even more?
Also what do you suggest for the image directory issue, integrity is not enforced in the database but with this idea it seems possible to maintain with application code and permitting access to the main directory to only the db.