Creating a "table"


(TahorSuiJuris) #1

Following the Northwind example, whereas the data is imported, I would need to know how to create a "table" AND I know this is NOT a term used in Neo4j.

MODEL of SUPPLIER table: https://i.imgur.com/lX0YwNY.png
MODEL of SUPPLIER table: https://i.imgur.com/olapxlX.png

Neo4j SUPPLIER table: https://i.imgur.com/QcjHd76.png

Q. How do I create a "table" - Node Label with all the fields?

I know how to create a NODE which is ONE row (record?), but not how to create multiple rows (records?).

A row is a NODE.
A table name is a label name.


(Ryan Boyd) #2

Hi there,

You're currently returning the node record by saying RETURN n in your Cypher.

If you want to instead return individual properties the result will be closer to looking like a table (and can be accessed as such programmatically as well).

ie:

MATCH 
  (n:Supplier)
RETURN
  n.country AS country, 
  n.contactName AS name,
  n.contactTitle AS title,
  n.phone AS phone

etc

That'll give you one row in the response for each :Supplier node and will include the properties ad individual columns.

Cheers,
-Ryan


(TahorSuiJuris) #3

@ryan.boyd
Thank you for the rapid reply.

This (RETURN) would create the individual columns? As in the example the data is imported, I want to create a new table. Is it better to create a new table with thousands of rows OUTSIDE of Neo4j? Then import it? I was hoping to be able to create a new table with thousands of rows/records using Cypher.


(Ryan Boyd) #4

Neo4j isn’t designed to store data in a tabular format. It’s intended to store Nodes and Relationships between those Nodes. Both Nodes and Relationships can have properties on them. Thus it’s possible to import any type of data (including tabular data), but it excels at highly related data.

You can use LOAD CSV to import tabular data, though you’ll need to map it to nodes and relationships during the import.

Cheers
Ryan


(TahorSuiJuris) #5

Thank you, yes I know. After concluding the Northwind example, the view offers the graph view as well as the table view.

I have been trying to create multiple nodes with no success as of yet.


(TahorSuiJuris) #6


(TahorSuiJuris) #7

The data is transactional relationship related, FIFO, whereas Purchases are related to Usage in calculating current inventory and value.


(TahorSuiJuris) #8

@ryan.boyd Thank you for your time and quick replies. I am trying to create a PURCHASE entity with 8 nodes/rows, with the 8th being a calculated node QUANTITY PURCHASED * UNIT PRICE.

Once I create and populate this entity, then I need to create a USAGE/SALES entity.


(TahorSuiJuris) #9

@ryan.boyd Companies like Amazon, Walmart, etc... has consumer data with name, address, city, etc... then connects various activities / relationships to that data. I am trying to do the same with the relationship being an inventory relationship based on an action / activity.


(Ameyasoft) #10

Q: I know how to create a NODE which is ONE row (record?), but not how to create multiple rows (records?).

You have to create one node for each row as each row in your table will have a different supplier id;
//row 1....
CREATE (s:Supplier {supplierid: 1, name:"Exotic Liquids'})
//row 2.....................
CREATE (s1:Supplier {supplierid: 2, name:"Clear Liquids'})

Q: The data is transactional relationship related, FIFO, whereas Purchases are related to Usage in calculating current inventory and value.

FIFO (First In First Out) applies to purchases or suppliers?

Also I do not see SupplierID in your 'Purchase' node. How do you connect purchase order with supplier id?

Let me know so that I can help you.


(TahorSuiJuris) #11

@ameyasoft Thank you for your kindness. I am creating the FIFO tables in MySQL with an HTML front end to perform the calculations, then hope to port MySQL over to Neo4j just as the Northwind example.

Neo4j is said to be faster and more stable than MySQL could ever be, thus the necessity of the move. I believe there are many applicable backend challenges that Neo4j can apply, especially with transactional relationship calculations, which is FIFO. May I please take you up on your offer and communicate back upon the completion of the back end three MySQL tables?


(Ameyasoft) #12

Sure. I did move data from MS SQL database to Neo4j using LOAD CSV and can try to help you.


(TahorSuiJuris) #13

Thank you for your kindness, shall communicate in two day.


(TahorSuiJuris) #14

@ameyasoft supplier is not of my making, as such no supplierID. Yes, the two keys would be necessary to connect the two "tables" / collection of "nodes". I am setting up the same in MySQL with a html front end. Q. I need to create data input fields (html front) to Neo4j (back), have you seen any instructions of how to do so?

"concept" example https://docs.wappler.io/t/connecting-to-a-database/2873