anyone ..?
On Friday, March 21, 2014 12:54:32 PM UTC-4, Dodong Juan wrote:
>
> I have the following DB:
>
>
> create class Customer extends V
>
> create class Car extends V
>
> create class Dealer extends V
>
> create class Owns extends E
>
>
> insert into Customer(first,last) values ('John','Doe')
>
> insert into Customer(first,last) values ('James','Bond')
>
> insert into Customer(first,last) values ('Tony','Stark')
>
>
>
> insert into Dealer(name,city,state) values ('Open Cars','New York','NY')
>
> insert into Dealer(name,city,state) values ('Side Cars','Jersey City','NJ')
>
>
> insert into Car(year,brand,model) values ('2014','Audi','R8')
>
> insert into Car(year,brand,model) values ('2012','Audi','TTRS')
>
> insert into Car(year,brand,model) values ('2014','BMW','M3')
>
> insert into Car(year,brand,model) values ('2012','Jaguar','XKJ')
>
>
>
> orientdb {testdb}> select from Car
>
>
> ----+-----+----+------+-----
>
> # |@RID |year|brand |model
>
> ----+-----+----+------+-----
>
> 0 |#13:0|2014|Audi |R8
>
> 1 |#13:1|2014|BMW |M3
>
> 2 |#13:2|2012|Jaguar|XKJ
>
> 3 |#13:3|2012|Audi |TTRS
>
> ----+-----+----+------+-----
>
>
> 3 item(s) found. Query executed in 0.0010 sec(s).
>
> orientdb {testdb}> select from Customer
>
>
> ----+-----+-----+-----
>
> # |@RID |first|last
>
> ----+-----+-----+-----
>
> 0 |#12:0|John |Doe
>
> 1 |#12:1|James|Bond
>
> 2 |#12:2|Tony |Stark
>
> ----+-----+-----+-----
>
>
> 3 item(s) found. Query executed in 0.0010 sec(s).
>
>
> //
>
> // Now create car ownership
>
> //
>
>
> // Tony owns all Audis
>
>
> orientdb {testdb}> create edge Owns from #12:2 to #13:0
>
>
> Created edge '[Owns{in:#13:0,out:#12:2}]' in 0.042000 sec(s).
>
>
> orientdb {testdb}> create edge Owns from #12:2 to #13:3
>
>
> Created edge '[Owns{in:#13:3,out:#12:2}]' in 0.004000 sec(s).
>
>
> // James owns BMW and and Audi R8
>
>
>
> orientdb {testdb}> create edge Owns from #12:1 to #13:0
>
> orientdb {testdb}> create edge Owns from #12:1 to #13:1
>
>
>
> So I can query for all the customer that owns an Audi
>
>
> orientdb {testdb}> select from (traverse in_Owns from (select from Car
> where brand='Audi')) where @class='Customer'
>
>
> ----+-----+--------+-----+-----
>
> # |@RID |out_Owns|first|last
>
> ----+-----+--------+-----+-----
>
> 0 |#12:2|[size=2]|Tony |Stark
>
> 1 |#12:1|[size=2]|James|Bond
>
> ----+-----+--------+-----+-----
>
>
>
> But how do I do the query if I want to display in a single table owner
> first , last and the year,brand,model of the car they own ..?
>
>
>
>
--
---
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.