forked from orientechnologies/orientdb-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
790 additions
and
780 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,34 @@ | ||
# Import from RDBMS | ||
|
||
*NOTE: Starting from OrientDB 2.0 you can use the [OrientDB-ETL module](https://github.com/orientechnologies/orientdb-etl/wiki/Import-from-DBMS) to import data from RDBMS. You can use ETL also with 1.7.x by installing it as separate module.* | ||
|
||
OrientDB supports a subset of SQL, so importing a database created as "Relational" is straightforward. For the sake of simplicity consider your Relational database having just these two tables: | ||
- POST | ||
- COMMENT | ||
|
||
Where the relationship is between Post and comment as One-2-Many. | ||
|
||
``` | ||
TABLE POST: | ||
+----+----------------+ | ||
| id | title | | ||
+----+----------------+ | ||
| 10 | NoSQL movement | | ||
| 20 | New OrientDB | | ||
+----+----------------+ | ||
TABLE COMMENT: | ||
+----+--------+--------------+ | ||
| id | postId | text | | ||
+----+--------+--------------+ | ||
| 0 | 10 | First | | ||
| 1 | 10 | Second | | ||
| 21 | 10 | Another | | ||
| 41 | 20 | First again | | ||
| 82 | 20 | Second Again | | ||
+----+--------+--------------+ | ||
``` | ||
|
||
- [Import using the Document Model (relationships as links)](Import-RDBMS-to-Document-Model.md) | ||
- [Import using the Graph Model (relationships as edges)](Import-RDBMS-to-Graph-Model.md) | ||
<!-- proofread 2015-12-11 SAM --> | ||
# Import from RDBMS | ||
|
||
*NOTE: As of OrientDB 2.0, you can use the [OrientDB-ETL module](https://github.com/orientechnologies/orientdb-etl/wiki/Import-from-DBMS) to import data from an RDBMS. You can use ETL also with 1.7.x by installing it as a separate module.* | ||
|
||
OrientDB supports a subset of SQL, so importing a database created as "Relational" is straightforward. For the sake of simplicity, consider your Relational database having just these two tables: | ||
- POST | ||
- COMMENT | ||
|
||
Where the relationship is between Post and comment as One-2-Many. | ||
|
||
``` | ||
TABLE POST: | ||
+----+----------------+ | ||
| id | title | | ||
+----+----------------+ | ||
| 10 | NoSQL movement | | ||
| 20 | New OrientDB | | ||
+----+----------------+ | ||
TABLE COMMENT: | ||
+----+--------+--------------+ | ||
| id | postId | text | | ||
+----+--------+--------------+ | ||
| 0 | 10 | First | | ||
| 1 | 10 | Second | | ||
| 21 | 10 | Another | | ||
| 41 | 20 | First again | | ||
| 82 | 20 | Second Again | | ||
+----+--------+--------------+ | ||
``` | ||
|
||
- [Import using the Document Model (relationships as links)](Import-RDBMS-to-Document-Model.md) | ||
- [Import using the Graph Model (relationships as edges)](Import-RDBMS-to-Graph-Model.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,45 @@ | ||
# Import a tree structure | ||
|
||
If you have a tree structure on RDBMS or CSV file and you want to import it in OrientDB, the ETL comes in the rescue. In this example we used CSV for the sake of simplicity, but it's the same with JDBC input and a SQL query against a RDBMS. | ||
|
||
## source.csv | ||
``` | ||
ID,PARENT_ID,LAST_YEAR_INCOME,DATE_OF_BIRTH,STATE | ||
0,-1,10000,1990-08-11,Arizona | ||
1,0,12234,1976-11-07,Missouri | ||
2,0,21322,1978-01-01,Minnesota | ||
3,0,33333,1960-05-05,Iowa | ||
``` | ||
|
||
## etl.json | ||
```json | ||
{ | ||
"source": { "file": { "path": "source.csv" } }, | ||
"extractor": { "row": {} }, | ||
"transformers": [ | ||
{ "csv": {} }, | ||
{ "vertex": { "class": "User" } }, | ||
{ "edge": { | ||
"class": "ParentOf", | ||
"joinFieldName": "PARENT_ID", | ||
"direction": "in", | ||
"lookup": "User.ID", | ||
"unresolvedLinkAction": "SKIP" | ||
} | ||
} | ||
], | ||
"loader": { | ||
"orientdb": { | ||
"dbURL": "plocal:/temp/mydb", | ||
"dbType": "graph", | ||
"classes": [ | ||
{"name": "User", "extends": "V"}, | ||
{"name": "ParentOf", "extends": "E"} | ||
], "indexes": [ | ||
{"class":"User", "fields":["ID:Long"], "type":"UNIQUE" } | ||
] | ||
} | ||
} | ||
} | ||
<!-- proofread 2015-12-11 SAM --> | ||
# Import a tree structure | ||
|
||
If you have a tree structure in an RDBMS or CSV file and you want to import it in OrientDB, the ETL can come to your rescue. In this example, we use CSV for the sake of simplicity, but it's the same with JDBC input and a SQL query against an RDBMS. | ||
|
||
## source.csv | ||
``` | ||
ID,PARENT_ID,LAST_YEAR_INCOME,DATE_OF_BIRTH,STATE | ||
0,-1,10000,1990-08-11,Arizona | ||
1,0,12234,1976-11-07,Missouri | ||
2,0,21322,1978-01-01,Minnesota | ||
3,0,33333,1960-05-05,Iowa | ||
``` | ||
|
||
## etl.json | ||
```json | ||
{ | ||
"source": { "file": { "path": "source.csv" } }, | ||
"extractor": { "row": {} }, | ||
"transformers": [ | ||
{ "csv": {} }, | ||
{ "vertex": { "class": "User" } }, | ||
{ "edge": { | ||
"class": "ParentOf", | ||
"joinFieldName": "PARENT_ID", | ||
"direction": "in", | ||
"lookup": "User.ID", | ||
"unresolvedLinkAction": "SKIP" | ||
} | ||
} | ||
], | ||
"loader": { | ||
"orientdb": { | ||
"dbURL": "plocal:/temp/mydb", | ||
"dbType": "graph", | ||
"classes": [ | ||
{"name": "User", "extends": "V"}, | ||
{"name": "ParentOf", "extends": "E"} | ||
], "indexes": [ | ||
{"class":"User", "fields":["ID:Long"], "type":"UNIQUE" } | ||
] | ||
} | ||
} | ||
} | ||
``` |
Oops, something went wrong.