Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-21-2021 10:11 AM
Hi everyone,
I am a newbie in Neo4j and trying to learn Neo4j by converting a relational database into a neo4j model.
So far I have nodes for
Relations
Report and CurrentInventory, no clue whether they belong to either node or relation.
CREATE (USA:Country)
CREATE (India:Country)
CREATE (USD:Currency {code: "USD", name: "Dollar", is_active: true, is_base_currency: true})
CREATE (INR:Currency {code: "INR", name: "Rupee", is_active: true, is_base_currency: true})
CREATE (USD) -[:CURRENCY_USED {date_from: "", date_to: ""}]-> (USA)
CREATE (INR) -[:CURRENCY_USED {date_from: "", date_to: ""}]-> (India)
CREATE (INR:CurrencyRate {code: "INR", name: "Rupee", is_active: true, is_base_currency: true})
CREATE (INR:CurrencyRate {code: "INR", name: "Rupee", is_active: true, is_base_currency: true})
CREATE (Tesla:Item {code: "TSLA", name: "Tesla", is_active: true })
CREATE (TeslaPrice:Price {buy: 400, sell: 399, timestamp: datetime()})
CREATE (Tesla) -[:ITEM_PRICE]-> (TeslaPrice)
CREATE (TeslaPrice) -[:ITEM_CURRENCY]-> (USD)
CREATE (Adam:Trader {first_name: "Adam", last_name: "West", user_name: "adam", password: "12345"})
CREATE (Adam) -[:TRADER_COUNTRY]-> (USA)
CREATE (Adam) -[:TRADER_CURRENCY]-> (USD)
CREATE (AdamPortfolio:Portfolio {quantity: 10})
CREATE (AdamPortfolio:Portfolio) -[:PORTFOLIO_ITEM]-> (Tesla)
CREATE (AdamPortfolio:Portfolio) -[:TRADER_PORTFOLIO]-> (Adam)
CREATE (AdamBuyTesla:Trade {qunatity: 10, unit_price: 400})
CREATE (AdamBuyTeslaOffer:Offer {qunatity: 10, unit_price: 400, buy: true, sell: false, timestamp: datetime()})
CREATE (AdamBuyTesla) -[:TRADE_OFFER]-> (AdamBuyTeslaOffer)
02-21-2021 05:05 PM
I think the design of the graph depends on what kind of queries you do.
What type of queries do you use most often?
Also, what is the volume and speed of your records?
02-21-2021 05:39 PM
It is a good start. The best part is you can start with a schema and then refactor as you figure out the questions you want to ask.
02-21-2021 06:07 PM
Thank you very much for the reply. Most would be read queries on the Items with few trades which will be create and updates.
Would like to maintain a portfolio of all the trades which is done in a separate table (CurrentInventory) in relational database.
Also other option is to just create Node for every table and create relations for the foreign key.
Atleast would be simple for my understanding as I have bit of experience with Relational database
03-25-2021 01:25 AM
If you are exploring Neo4j, please use Neo4j ETL to link your relational database to neo4j and check the graphs formed according to the keys defined on the RDBMS. Below is the link for your reference .
Thanks
All the sessions of the conference are now available online