I´m twisting my head now for a while and don´t get to a final solution. So I hope I might find some exchange or help on how to solve this issue here on an architectural level.
I´m currently facing the following scenario: I want to write a web-application (I do it with Java, but this is not really relevant for a solution, as this is currently an question on a higher level), where there is this kind of relation:
Event --1:n--> Team --1:n--> Participant
Meaning: I have an event, in which will be a number of teams, having a number of participants. So far so good - this would be an easy relation in a SQL-database.
But then there is also a directory-tree, representing the same relation in a file-structure:
+--event1
| +--team1
| | +--participant1
| | +--participant2
| | +--participant3
| +--team2
| | +--participant4
| +--team3
+--event2
| +--team4
...
(I think, you got the idea) So in each participant´s directory are numerous files, which are copied to this directory via the file-system. Whenever there is a directory on the file-system, this should be connected to a corresponding entry in the database, where there is some additional data, that should be displayed together with the files in the web-GUI. It is not defined, what will be there at first (database-entry or directory) as this is operated by different users.
Now there are a couple of things to keep in mind, which make kind of sense to me:
- When a directory-name changes (either event, team or participant), it should still relate to the same entry in the database (because there might be other entities, which still relate for example to a participant)
- The directory of any event/team/participant might be deleted - the data in the database should then remain. BUT - if a new directory with the same name is created again at a later time and the event is 'closed', this directory will then point to a new database-entry (e.g. a new event). If the event is still active, then the creation of a directory with the same name should map to the previously assigned entry in the database.
- Ideally a creation of a directory already leads to the creation of an corresponding database-entry.
- It should also be possible to create an event/team/participant in the web-GUI, which then automatically creates a corresponding directory on the filesystem.
I hope my description is good enough to understand the scenario. I already have some things in mind, but all of them don´t really convince myself to be a robust solution. So hopefully one of you already have some idea on that. I´m pretty open to any technology or framework, which might help to solve this problem.
I´m looking forward to your ideas and a nice discussion!
Thanks for your help!
First of all the uniqueness of the directories must be designed. Did you consider to use hidden file, containing a unique key, inside of each watched directory? If there's no hi-load system, the creation time might be used.
Having the unique key in the file system it's no so hard to reflect the existing unique keys in the database and organize synchronization between two storages.