Database Tables
File Table
| file_uid | file_id | revision_id | file_name | file_length | directory_id | directory_path | parent_file_id | data | deleted_flag | end_time | stream_id |
- unique_internal_id - The id for indexing, parent id's and journaling
- file_id - The internal ID of the file
- revision_id - The current revision that the file is at
- file_name - The name of the file
- file_length - The length of the file's data
- directory_path - where the file actually "lives"
- parent_id - the file_id of parent of the current file, exists when the current file is branched
- data - A binary diff of the current revision and the last revision of if it's the most current version, the file itself
- deleted_flag - A boolean flag that determines if the file is deleted or not
- end_time - The time at which the file was made
- stream_id - A reference to the stream that belongs to the file
Directory Table
| directory_id | parent_id | directory_path | revision_id | start_time | end_time | stream_id |
- directory_id - The internal ID of the directory
- parent_id - The internal ID of the directory's parent
- directory_path - The name of the directory
- revision_id - The revision of the directory
- start_time - When the directory was born (double check)
- end_time - When the directory was last editted (double check)
- stream_id - A reference to the stream that belongs to the file
Stream
| stream_id | stream_name | stream |
- stream_id - The internal ID of the stream
- stream_name - The name of the stream, it is UTF-8
- stream - binary stream, can hold anything
Database Wrapper API
- constructor ( string host, uint port, string dbname, string user, string password )
- uint get_file_id ( string file_path )
SELECT file_id FROM file WHERE file_name = 'some_name' AND directory_path = 'some_path' LIMIT 1
- file get_file ( uint file_id )
SELECT revision_id, file_name, file_length, directory_path, parent_file_id, deleted_flag, end_time, stream_id FROM file WHERE file_id = 'some_id' AND revision_id = (SELECT MAX(revision_id) FROM file WHERE file_id = 'some_id')
- file get_file ( uint file_id, uint revision )
SELECT file_name, file_length, directory_path, parent_file_id, deleted_flag, end_time, stream_id FROM file WHERE file_id = 'some_id' AND revision_id = 'some_revision_id'
- char* get_file_data ( uint file_id, uint revision )
SELECT data FROM file WHERE file_id = 'some_id' AND revision_id = 'some_revision_id'
- char* get_file_data ( uint file_id )
SELECT data FROM file WHERE file_id = 'some_id' AND revision_id = (SELECT MAX(revision_id) FROM file WHERE file_id = 'some_id')
- uint get_file_max_revision ( uint file_id )
SELECT MAX(revision_id) FROM file WHERE file_id = 'some_id'
- list < file > get_files ( string sql_command )
- uint get_directory_id ( string file_path )
SELECT directory_id FROM directory WHERE directory_path = 'some_path' AND revision_id = (SELECT MAX(revision_id) FROM directory WHERE directory_path = 'some_path')
- dir get_directory ( uint directory_id )
SELECT * FROM directory WHERE directory_id = 'some_id' AND revision_id = (SELECT MAX(revision_id) FROM directory WHERE directory_id = 'some_id')
- dir get_directory ( uint directory_id, uint revision )
SELECT * FROM directory WHERE directory_id = 'some_id' AND revision_id = 'some_id'
- list < dir > get_directories ( string sql_command )
