How can I get the same effect in OrientDB query as with JOIN SQL in relational databases?
I have classes in OrientDB
CREATE Class Continent;CREATE Class Country;CREATE Class City;
//Hong KongINSERT INTO City set name = 'Tsuen Wan';INSERT INTO City set name = 'Sha Tin';INSERT INTO City set name = 'Tuen Mun New Town';
//DenmarkINSERT INTO City set name = 'Copenhagen';0INSERT INTO City set name = 'Aarhus';INSERT INTO City set name = 'Odense';
//FranceINSERT INTO City set name = 'Paris';INSERT INTO City set name = 'Marseille';INSERT INTO City set name = 'Lyon';
INSERT INTO Country set name = 'Hong Kong', cities=(SELECT FROM City WHERE name in ['Tsuen Wan', 'Sha Tin', 'Tuen Mun New Town']);INSERT INTO Country set name = 'Denmark', cities=(SELECT FROM City WHERE name in ['Copenhagen', 'Aarhus', 'Odense']);INSERT INTO Country set name = 'France', cities=(SELECT FROM City WHERE name in ['Paris', 'Marseille', 'Lyon']);
INSERT INTO Continent set name='Asia', countries=(SELECT FROM Country WHERE name = 'Hong Kong');INSERT INTO Continent set name='Europe', countries=(SELECT FROM Country WHERE name in ['Denmark', 'France']);
which is the equivalent of the SQL tables
CREATE TABLE Continent ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100));
CREATE TABLE Country ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), continent_id INT, foreign key (continent_id) references Continent(id));
CREATE TABLE City ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), country_id INT, foreign key (country_id) references Country(id));
How to make a query using data from these three classes, which will return
CITY COUNTRY CONTINENT Copenhagen Denmark EuropeAarhus Denmark EuropeOdense Denmark EuropeParis France EuropeMarseille France EuropeLyon France EuropeTsuen Wan Hong Kong AsiaSha Tin Hong Kong AsiaTuen Mun New Town Hong Kong Asia
Something like in SQL
FROM City city, Country country, Continent continentWHEREcity.country_id=country.id and continent.id=country.continent_id;