Hi everyone,
I am a newbie in Neo4j and trying to learn Neo4j by converting a relational database into a neo4j model.
I am confused when a table is a node or a relation.
So far I have nodes for
- Trader
- Country
- Currency
- Item (Stock, Currency, or fund)
- Price(? should this be relation)
- Offer(Should trade or offer to be a relation)
- Rate (Currency conversion rate)
Relations
- CURRENCY_USED
- ITEM_PRICE
- ITEM_CURRENCY
- TRADER_COUNTRY
- TRADER_CURRENCY
- TRADE
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)