-
Notifications
You must be signed in to change notification settings - Fork 664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OrientDB graph search support #131
Comments
Thank you very much! http://orientdb.com/docs/last/SQL.html |
Good morning, I reviewed OrientDB documentation and course (it is very impressive), and I
Best regards, Andrey 2015-04-19 12:59 GMT+03:00 Xianliang Wu notifications@github.com:
|
After some research I think that we can add the following commands to AlaSQL to support some features, exists in OrientDB. Unfortunately, we can not provide 100% compatibility of SQL dialect, because AlaSQL already uses some keywords. Below is the proposed list: 1. Document-oriented database (# operator) CREATE CLASS Person (name STRING, age INT, city);
CREATE CLASS City (name STRING, country);
CREATE CLASS Country (name STRING);
INSERT INTO Person SET name = "Romeo", age=33,
city = (INSERT INTO City SET name = "Milano",
country = (INSERT INTO Country SET name = "Italy"));
SET @italy = (SELECT FROM Country WHERE name = "Italy");
INSERT INTO Person SET name = "Paola", age=25,
city = (INSERT INTO City SET name = "Venice", country = @italy;
SELECT name, age, city#name FROM Person WHERE city#country#name = "Italy";
SELECT @italy#name; Here INSERT operator returns number of inserted object. 2. SEARCH (traverse) operator on JSON object and documents SET @data = @[{a:1,b:{c:1,d:25}},{a:1,b:23}];
SEARCH a b c=1 parent() FROM @data WHERE d > 20;
-- returns {c:1,d:25}
SEARCH a b c=1 parent() FROM @data WHERE d > 20
WHILE depth()<2 STRATEGY DEPTH_FIRST;
-- returns
SEARCH city # country # parent() # parent() name FROM Person;
-- returns "Romeo", "Paola" 3. Graph support SET @word1 = (CREATE VERTEX Word SET name = "John");
SET @word2 = (CREATE VERTEX Word word2 SET name = "Maria");
SET @word3 = (CREATE VERTEX Word word3 SET name = "Peter");
CREATE EDGE e12 FROM @word1 TO @word2 SET name="buy";
CREATE EDGE e23 FROM @word2 TO @word3 SET name="sell";
SEARCH out(name="buy") out(name="sell") name FROM @word1;
-- returns ["Peter"] 4. Mix SELECT country
FROM
(SEARCH any() fruit="Apple"
FROM {Africa:{fruit:"Banana",country:"Ghana"}, Europe:{fruit:"Apple",country:"Poland"},
America:{fruit:"Apple", country:"USA"}, Asia:{vedgetable:"Rice",country:"China"}}
LET continent = id()
)
WHERE continent = "Europe";
-- returns ["Poland"] These are only ideas of proposed syntax extension to AlaSQL. |
SEARCH syntax (unfortunately we can not use SELECT operator because parser ambigousity problems):
where selector can be a XPath string or number of arguments divided by spaces (AND) and/or commas (OR):
like:
Selector functions are:
|
Documents can be realized with AlaSQL tables and columns as properties. Plus, each database will have special
Object can have additional fields:
If you need to refer to another object by it's id, you need to use SELECT city#country#name FROM Person that means, that AlaSQL will look to the You can directly refer to the object from the storage with # operator: -- Age of persion with id 123
SELECT 123 # age
SET @myid = 123;
SET @myobj = #123;
SELECT @myid # age
SELECT @myobj -> age
SELECT #(@myid) -> age For compatibility with OrientDB we can use complex reference id, like: |
I started with classes. Here are some examples of operations with classes: (https://github.com/agershun/alasql/blob/develop/test/test302.js), including:
|
The very feature we need is Graph-Driven, vertexes and edges. I think others will agree with me. @lvca |
I am trying to figure it out these days and report them here as soon as I can. Thank you for your amazing works! |
@wuxianliang Any news on this? |
The differences between ordinary SQL and OrientDB SQL are in http://orientdb.com/docs/last/SQL.
The text was updated successfully, but these errors were encountered: