A vintage wine is one made from grapes that were all, or primarily, grown and harvested in a single specified year. For sales system, this can be a property of a wine. Here is my design:
CREATE (c1:Winery {id: "winery1", name: "Napa"})
CREATE (w1:Wine {id: "w1", name: "Red1"})
CREATE (w2:Wine {id: "w2", name: "Red2"})
CREATE (d1:Dealer {id: "DL1", name: "DLR1"})
CREATE (d2:Dealer {id: "DL2", name: "DLR2"})
CREATE (o1:Order {number:'PO100',date:'1/1/2017'})
CREATE (o2:Order {number:'PO200',date:'2/1/2017'})
CREATE (s1:Sold {price:100,qty:20,vintage:2015,ponbr:"PO100"})
CREATE (s2:Sold {price:120,qty:30,vintage:2010,ponbr:"PO100"})
CREATE (s3:Sold {price:90,qty:35,vintage:2000,ponbr:"PO200"})
CREATE (c1)-[:"VINTAGE_WINE"]->(w1)
CREATE (c1)-[:"VINTAGE_WINE"]->(w2)
CREATE (c1)-[:"DEALER"]->(d1)
CREATE (c1)-[:"DEALER"]->(d2)
CREATE (d1)-[:"ORDERS"]->(o1)
CREATE (d1)-[:"ORDERS"]->(o2)
CREATE (w1)-[:"PART_OF_ORDER"]->(s1)
CREATE (w1)-[:"PART_OF_ORDER"]->(s2)
CREATE (w2)-[:"PART_OF_ORDER"]->(s3);
Wines sold with purchase order numbers:
MATCH (c:Winery)-[]->(w:Wine)-[]->(s:Sold)
WITH c, w, s
MATCH (c:Winery)-[]->(d:Dealer)-[]->(o:Order)
WHERE o.number = s.ponbr
WITH c, d, w, s
Filter by vintage year:
MATCH (c:Winery)-[]->(w:Wine)-[]->(s:Sold)
WHERE s.vintage = 2010
Every purchase order can also be reconciled by adding 'TotAmt' property to 'Order' node and totaling the wines sold.
Hope this will help you.
-Kamal