Thanks for the reply! Whipped up a demonstration for you.
Here is a simple example database I made following a similar model to the 
posts/comments example in the 'migrating from rdbms' article:

CREATE CLASS Drive;
CREATE PROPERTY Drive.drive_ID LONG;
CREATE PROPERTY Drive.drive_name STRING;
CREATE INDEX Drive.drive_ID UNIQUE;

CREATE CLASS Folder;
CREATE PROPERTY Folder.folder_ID LONG;
CREATE PROPERTY Folder.folder_drive_ID LONG;
CREATE PROPERTY Folder.folder_name STRING;
CREATE INDEX Folder.folder_ID UNIQUE;

CREATE CLASS File;
CREATE PROPERTY File.file_folder_ID LONG;
CREATE PROPERTY File.file_name STRING;

INSERT INTO Drive (drive_ID, drive_name) VALUES (1, "drive1")
INSERT INTO Drive (drive_ID, drive_name) VALUES (2, "drive2")
INSERT INTO Folder (folder_ID, folder_drive_ID, folder_name) VALUES (1, 1, 
"folder1")
INSERT INTO Folder (folder_ID, folder_drive_ID, folder_name) VALUES (2, 1, 
"folder2")
INSERT INTO Folder (folder_ID, folder_drive_ID, folder_name) VALUES (3, 2, 
"folder3")
INSERT INTO File (file_folder_ID, file_name) VALUES (1, "file1")
INSERT INTO File (file_folder_ID, file_name) VALUES (2, "file2")
INSERT INTO File (file_folder_ID, file_name) VALUES (3, "file3")
INSERT INTO File (file_folder_ID, file_name) VALUES (3, "file4")

CREATE LINK folder_link TYPE linkset FROM Folder.folder_drive_ID To 
Drive.drive_ID INVERSE
CREATE LINK file_link TYPE linkset FROM File.file_folder_ID To 
Folder.folder_ID INVERSE

UPDATE folder REMOVE folder_drive_ID
UPDATE file REMOVE file_folder_ID


After all this is done I run a query that I believe should work:
select * from folder where file.file_name = "file1"
0 item(s) found. Query executed in 0.003 sec(s).

I believe this should have return my record for folder1? Hopefully I just 
made some simple mistake you can spot :/


On Thursday, March 12, 2015 at 9:16:58 AM UTC-7, Colin wrote:
>
> Welcome,
>
> You were on the right track, initially with making drives, folders, files 
> classes and linking them together.  OrientDB's real power lies in its 
> hybrid graph/database capabilities.  So, linking objects together allows 
> you to access and query the data very quickly instead of having to retrieve 
> one object, get the id you need, and then query the database again.
>
> I'd have to see an example of the data and the query you used to try to 
> understand why your results returned zero.
>
> Another design idea: Often folders are also files, so your folder class 
> could extend the file class and inherit its properties.
>
> Don't forget that you can use a vertex as a document but add edges to it 
> (instead of document links).  The DB will handle managing the links, and 
> the links are bi-directional.
>
> Are you planning to stick with SQL or also use the Java API?
>
> Good luck!
>
> -Colin
>
> Orient Technologies
>
> The Company behind OrientDB
>
>
> On Thursday, March 12, 2015 at 3:56:58 AM UTC-5, Ghosty Huan wrote:
>>
>> Hi, I'm currently testing out Orientdb 2.0.2 by implementing a document 
>> database that was originally designed for a rdbms. I do not have any old 
>> data to import so if I was wondering if anyone has suggestions on the best 
>> way to implement the following requirements specifically in Orient. I have 
>> attempted using the online guide for migrating from an rdbms but it has 
>> proved troublesome so I thought I would ask here and make sure I'm on the 
>> right path or if Orient has a feature I'm overlooking.
>>
>> A simplified idea of my data is this:
>>
>> Drive
>> =======
>> driveID
>> other properties...
>>
>> Folder
>> =======
>> folderID
>> FK_driveID
>> other properties...
>>
>> File
>> =======
>> fileID
>> FK_folderID
>>
>> As for requirements:
>> I need to be able to have join like behavior in queries. For example I 
>> need to select files based on the properties of their parent folders/drives 
>> or select drives based properties of their folders/files.
>> I previously tried to do this with drives/folders/files as their own 
>> classes with links inbetween as the 'migrating from rdbms' guide showed, 
>> but when I queried a drive based on folder properties(or vice versa) it 
>> would return 0 results. No clue why this happened because if I queried for 
>> the links field in drive they were all correct references to records in 
>> folder.
>>
>> I need to be able to insert new drives/folder/files with new links. When 
>> I first browsed orientDB's documentation I did not realize that CREATE LINK 
>> only affected existing data and to insert new data you must manually insert 
>> a new link by querying for the correct RID to link. Is there is a way for 
>> me to avoid this or avoid links altogether by embedding classes or some 
>> other technique?
>>
>> So in summary, does anyone have a suggestion for a implementing this 
>> using Orient's specific capabilities? If not, and the 'migrating from 
>> rdbms' approach is correct then any clue why why my joined queries would 
>> return zilch?
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to