Thanks for the reply.

The query which you suggested creates edge only from Corp to direct 
children of corp (i.e. Districts)

I want to create edge from districts to small offices as well. Note that in 
real world I have 10k+ office nodes and it will be extremely painful to do 
it for each node by hand. 

If this is not possible to do using SQL then I will write a program to do 
it.


On Friday, 29 May 2015 16:51:57 UTC+5:30, normanLinux wrote:
>
> Sorry, I missed part of your original post.  Mea Culpa
> You are on exactly the right track
> create edge from (select from NodeX where id="Corp") to (select from NodeX 
> where parent_id = "Corp")
>
> That should do it.  Of course, this will also create the self-referencing 
> link from Corp to Corp. 
>
> In my postgres version top level items had a 0 parent_id
>
> On Friday, 29 May 2015 10:45:18 UTC+1, Kapil Ranade wrote:
>>
>> Hi Alessandro,
>>
>> Currently there is only one class called NODE having three fields
>>
>> id, name, parent_id
>>
>> All I wish to do is create "Parent -> Child" edges in nodes created using 
>> above class.
>>
>> Here is sample class and data creation script (Note that I have to add 
>> more than 10k offices in real life):
>>
>> create class NodeX extends V
>> create property NodeX.id string
>> create property NodeX.name string
>> create property NodeX.parent_id string
>>
>> CREATE VERTEX NodeX CONTENT {"id":"Corp", "name" : "Corporate Office", 
>> "parent_id" : "Corp" }
>> CREATE VERTEX NodeX CONTENT {"id":"D1", "name" : "District Office 1", 
>> "parent_id" : "Corp" }
>> CREATE VERTEX NodeX CONTENT {"id":"D2", "name" : "District Office 2", 
>> "parent_id" : "Corp" }
>> CREATE VERTEX NodeX CONTENT {"id":"SO1", "name" : "Small Office 1", 
>> "parent_id" : "D1" }
>> CREATE VERTEX NodeX CONTENT {"id":"SO2", "name" : "Small Office 2", 
>> "parent_id" : "D2" }
>> CREATE VERTEX NodeX CONTENT {"id":"SO3", "name" : "Small Office 3", 
>> "parent_id" : "D1" }
>>
>>
>>
>> On Friday, 29 May 2015 13:11:04 UTC+5:30, alessand...@gmail.com wrote:
>>>
>>> Hi Kapil,
>>> have you got a screenshot of your schema ?
>>>
>>> Bye, Alessandro 
>>>
>>> Il giorno venerdì 29 maggio 2015 09:12:37 UTC+2, Kapil Ranade ha scritto:
>>>>
>>>> I have imported hierarchical data into OrientDB from RDMBS using OETL. 
>>>>
>>>> In RDBMS we used to store parentId in the same row. e.g. the table 
>>>> structure is something like this:
>>>>
>>>> ID - Name - Parent_ID
>>>>
>>>> Corp - Corporate Office - Corp
>>>>
>>>> D1 - District Office 1 - Corp
>>>>
>>>> D2 - District Office 2 - Corp
>>>>
>>>> SO1 - Small Office 1 - D1
>>>>
>>>> SO2 - Small Office 2 - D2
>>>>
>>>> SO3 - Small Office 3 - D1
>>>>
>>>> Now each row is a node in orientdb. I want to create an edge (ParentOf) 
>>>> from say Corp to D1 and D1 to SO1 and so on.
>>>>
>>>> How can I write a query to achieve this? Something along the line of 
>>>> following?
>>>>
>>>> create edge parentOf from (select from node)a to (select from node 
>>>> where a.id = parent_id)
>>>>
>>>>
>>>>

-- 

--- 
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 orient-database+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to