Skip to content

Commit

Permalink
Final changes
Browse files Browse the repository at this point in the history
  • Loading branch information
smolinari committed Dec 12, 2015
1 parent 437c827 commit 75f057c
Show file tree
Hide file tree
Showing 8 changed files with 790 additions and 780 deletions.
67 changes: 34 additions & 33 deletions Import-From-RDBMS.md
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)
87 changes: 44 additions & 43 deletions Import-a-tree-structure.md
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" }
]
}
}
}
```
Loading

0 comments on commit 75f057c

Please sign in to comment.