I want to do a simple versioning system but i don't have ideas on how to structure my datas, and my code.
Here is a short example:
Users should be able to see the tree. (the different version) The tree can only be up to 2 levels:
| |--File_A_0 \--File_A_1 \--File_A_2 \--File_A_3 \--File_A_4
There are also 2 types of file, a final (which is the latest approved version) and a draft version (which the latest uploaded file) The file will be physically stored on the server. Each files are owned by a user (or more) and only one group.
Edit: Groups represent a group of document, document could only be owned by ONE group at once. Users do NOT depend on groups.
Begin edit:
Here is what i did, but it is not really efficient !
id_article | relative_group_id | id_group | title | submited | date | abstract | reference | draft_version | count | status id_draft | id_file | version | date
But it's difficult to manage, to extend. I think it's because the group paramater...
End edit
So the questions are:
(The application is developped with PHP and Zend Framework, database should be mysql or postgresql)
Version control, also known as source control, is the practice of tracking and managing changes to software code. Version control systems are software tools that help software teams manage changes to source code over time.
The types of VCS are: Local Version Control System. Centralized Version Control System. Distributed Version Control System.
Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. For the examples in this book, you will use software source code as the files being version controlled, though in reality you can do this with nearly any type of file on a computer.
For God's sake, don't. You really don't want to go down this road.
Stop and think about the bigger picture for a moment. You want to keep earlier versions of documents, which means that at some point, somebody is going to want to see some of those earlier versions, right? And then they are going to ask, "What's the difference between version 3 and version 7"? And then they are going to say, "I want to roll back to version 3, but keep some of the changes that I put in version 5, ummm, ok?"
Version control is non-trivial, and there's no need to reinvent the wheel-- there are lots of viable version control systems out there, some of them free, even.
In the long run, it will be much easier to learn the API of one of these systems, and code a web front-end that offers your users the subset of features they are looking for (now.)
You wouldn't code a text editor for your users, would you?
You may get inspiration from there.
Concerning your comment :
As for a database structure, you may try this kind of structure (MySQL sql) :
CREATE TABLE `Users` ( `UserID` INT NOT NULL AUTO_INCREMENT , `UserName` CHAR(50) NOT NULL , `UserLogin` CHAR(20) NOT NULL , PRIMARY KEY (`UserID`) ); CREATE TABLE `Groups` ( `GroupID` INT NOT NULL AUTO_INCREMENT , `GroupName` CHAR(20) NOT NULL , PRIMARY KEY (`GroupID`) ); CREATE TABLE `Documents` ( `DocID` INT NOT NULL AUTO_INCREMENT , `GroupID` INT NOT NULL , `DocName` CHAR(50) NOT NULL , `DocDateCreated` DATETIME NOT NULL , PRIMARY KEY (`DocID`) , INDEX (`GroupID`) , CONSTRAINT `FK_Documents_1` FOREIGN KEY (`GroupID`) REFERENCES `Groups` (`GroupID`) ); CREATE TABLE `Revisions` ( `RevID` INT NOT NULL AUTO_INCREMENT , `DocID` INT , `RevUserFileName` CHAR(30) NOT NULL , `RevServerFilePath` CHAR(255) NOT NULL , `RevDateUpload` DATETIME NOT NULL , `RevAccepted` BOOLEAN NOT NULL , PRIMARY KEY (`RevID`) , INDEX (`DocID`) , CONSTRAINT `FK_Revisions_1` FOREIGN KEY (`DocID`) REFERENCES `Documents` (`DocID`) ); CREATE TABLE `M2M_UserRev` ( `UserID` INT NOT NULL , `RevID` INT NOT NULL , INDEX (`UserID`) , CONSTRAINT `FK_M2M_UserRev_1` FOREIGN KEY (`UserID`) REFERENCES `Users` (`UserID`) , INDEX (`RevID`) , CONSTRAINT `FK_M2M_UserRev_2` FOREIGN KEY (`RevID`) REFERENCES `Revisions` (`RevID`) );
Documents is a logical container, and Revisions contains actual links to the files. Whenever a person updates a new file, create an entry in each of these tables, the one in Revisions containing a link to the one inserted in Documents.
The table M2M_UserRev allows to associate several users to each revision of a document.
When you update a document, insert only in Revisions, with alink to the corresponding Document. To know which document to link to, you may use naming conventions, or asking the user to select the right document.
For the file system architecture of your files, it really doesn't matter. I would just rename my files to something unique before they are stored on the server, and keep the user file name in the database. Just store the files renamed in a folder anywhere, and keep the path to it in the database. This way, you know how to rename it when the user asks for it. You may as well keep the original name given by the user if you are sure it will be unique, but I wouldn't rely on it too much. You may soon see two different revisions having the same name and one overwriting the other on your file system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With