Relation cli sample session
MacBook-Pro:~ matti$ ./relation
Relation 1.0 © 2019 belle-nuit.com
> // Select all the data from the products, including all the data for each product's manufacturer.
Select all the data from the products, including all the data for each product's manufacturer.
> read products.csv
+> read manufacturers.csv
++> join natural
+> print
┌────────┬─────────────────┬───────┬───────┬─────────────────┐
│ itemid │ name │ price │ manid │ manufacturer │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 1 │ Hard drive │ 240 │ 5 │ Fujitsu │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 2 │ Memory │ 120 │ 6 │ Winchester │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 3 │ ZIP drive │ 150 │ 4 │ Iomega │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 4 │ Floppy disk │ 5 │ 6 │ Winchester │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 5 │ Monitor │ 240 │ 1 │ Sony │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 6 │ DVD drive │ 180 │ 2 │ Creative Labs │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 7 │ CD drive │ 90 │ 2 │ Creative Labs │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 8 │ Printer │ 270 │ 3 │ Hewlett Packard │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 9 │ Toner cartridge │ 66 │ 3 │ Hewlett Packard │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 10 │ DVD burner │ 180 │ 2 │ Creative Labs │
└────────┴─────────────────┴───────┴───────┴─────────────────┘
+> / Select the average price of each manufacturer's products, showing only the manufacturer's code.
Say what? Did you mean "/ Select the average price of each manufacturer's products, showing only the manufacturer's code."?
+> // Select the average price of each manufacturer's products, showing only the manufacturer's code.
Select the average price of each manufacturer's products, showing only the manufacturer's code.
+> read products.csv
++> project manid, price avg
++> print
┌───────┬───────────┐
│ manid │ price_avg │
├───────┼───────────┤
│ 5 │ 240 │
├───────┼───────────┤
│ 6 │ 62.5 │
├───────┼───────────┤
│ 4 │ 150 │
├───────┼───────────┤
│ 1 │ 240 │
├───────┼───────────┤
│ 2 │ 150 │
├───────┼───────────┤
│ 3 │ 168 │
└───────┴───────────┘
++> // Select the average price of each manufacturer's products, showing the manufacturer's name.
Select the average price of each manufacturer's products, showing the manufacturer's name.
++> read manufacturers.csv
+++> join natural
++> project manufacturer, price_avg
++> print
┌─────────────────┬───────────┐
│ manufacturer │ price_avg │
├─────────────────┼───────────┤
│ Fujitsu │ 240 │
├─────────────────┼───────────┤
│ Winchester │ 62.5 │
├─────────────────┼───────────┤
│ Iomega │ 150 │
├─────────────────┼───────────┤
│ Sony │ 240 │
├─────────────────┼───────────┤
│ Creative Labs │ 150 │
├─────────────────┼───────────┤
│ Hewlett Packard │ 168 │
└─────────────────┴───────────┘
++> write average.csv
++> read average.csv
+++> print
┌─────────────────┬───────────┐
│ manufacturer │ price_avg │
├─────────────────┼───────────┤
│ Fujitsu │ 240 │
├─────────────────┼───────────┤
│ Winchester │ 62.5 │
├─────────────────┼───────────┤
│ Iomega │ 150 │
├─────────────────┼───────────┤
│ Sony │ 240 │
├─────────────────┼───────────┤
│ Creative Labs │ 150 │
├─────────────────┼───────────┤
│ Hewlett Packard │ 168 │
└─────────────────┴───────────┘
+++> history
1: // Select all the data from the products, including all the data for each product's manufacturer.
2: read products.csv
3: read manufacturers.csv
4: join natural
5: print
6: // Select the average price of each manufacturer's products, showing only the manufacturer's code.
7: read products.csv
8: project manid, price avg
9: print
10: // Select the average price of each manufacturer's products, showing the manufacturer's name.
11: read manufacturers.csv
12: join natural
13: project manufacturer, price_avg
14: print
15: write average.csv
16: read average.csv
17: print
+++> edit 9+ select price_avg >= 150
+++> history
1: // Select all the data from the products, including all the data for each product's manufacturer.
2: read products.csv
3: read manufacturers.csv
4: join natural
5: print
6: // Select the average price of each manufacturer's products, showing only the manufacturer's code.
7: read products.csv
8: project manid, price avg
9: select price_avg >= 150
10: print
11: // Select the average price of each manufacturer's products, showing the manufacturer's name.
12: read manufacturers.csv
13: join natural
14: project manufacturer, price_avg
15: print
16: write average.csv
17: read average.csv
18: print
+++> run
Select all the data from the products, including all the data for each product's manufacturer.
┌────────┬─────────────────┬───────┬───────┬─────────────────┐
│ itemid │ name │ price │ manid │ manufacturer │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 1 │ Hard drive │ 240 │ 5 │ Fujitsu │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 2 │ Memory │ 120 │ 6 │ Winchester │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 3 │ ZIP drive │ 150 │ 4 │ Iomega │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 4 │ Floppy disk │ 5 │ 6 │ Winchester │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 5 │ Monitor │ 240 │ 1 │ Sony │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 6 │ DVD drive │ 180 │ 2 │ Creative Labs │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 7 │ CD drive │ 90 │ 2 │ Creative Labs │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 8 │ Printer │ 270 │ 3 │ Hewlett Packard │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 9 │ Toner cartridge │ 66 │ 3 │ Hewlett Packard │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 10 │ DVD burner │ 180 │ 2 │ Creative Labs │
└────────┴─────────────────┴───────┴───────┴─────────────────┘
Select the average price of each manufacturer's products, showing only the manufacturer's code.
┌───────┬───────────┐
│ manid │ price_avg │
├───────┼───────────┤
│ 5 │ 240 │
├───────┼───────────┤
│ 4 │ 150 │
├───────┼───────────┤
│ 1 │ 240 │
├───────┼───────────┤
│ 2 │ 150 │
├───────┼───────────┤
│ 3 │ 168 │
└───────┴───────────┘
Select the average price of each manufacturer's products, showing the manufacturer's name.
┌─────────────────┬───────────┐
│ manufacturer │ price_avg │
├─────────────────┼───────────┤
│ Fujitsu │ 240 │
├─────────────────┼───────────┤
│ Iomega │ 150 │
├─────────────────┼───────────┤
│ Sony │ 240 │
├─────────────────┼───────────┤
│ Creative Labs │ 150 │
├─────────────────┼───────────┤
│ Hewlett Packard │ 168 │
└─────────────────┴───────────┘
┌─────────────────┬───────────┐
│ manufacturer │ price_avg │
├─────────────────┼───────────┤
│ Fujitsu │ 240 │
├─────────────────┼───────────┤
│ Iomega │ 150 │
├─────────────────┼───────────┤
│ Sony │ 240 │
├─────────────────┼───────────┤
│ Creative Labs │ 150 │
├─────────────────┼───────────┤
│ Hewlett Packard │ 168 │
└─────────────────┴───────────┘
+++> // Select the name and price of the cheapest product.
Select the name and price of the cheapest product.
+++> read products.csv
++++> dup
+++++> project price min
+++++> join 1
++++> select price = price_min
++++> project name, price
++++> print
┌─────────────┬───────┐
│ name │ price │
├─────────────┼───────┤
│ Floppy disk │ 5 │
└─────────────┴───────┘
++++> // Select the name of each manufacturer along with the name and price of its most expensive product.
Select the name of each manufacturer along with the name and price of its most expensive product.
++++> read products.csv
+++++> project manid, price max
+++++> read products.csv
++++++> join natural
+++++> select price = price_max
+++++> read manufacturers.csv
++++++> join natural
+++++> project manufacturer, name, price
+++++> print
┌─────────────────┬────────────┬───────┐
│ manufacturer │ name │ price │
├─────────────────┼────────────┼───────┤
│ Fujitsu │ Hard drive │ 240 │
├─────────────────┼────────────┼───────┤
│ Winchester │ Memory │ 120 │
├─────────────────┼────────────┼───────┤
│ Iomega │ ZIP drive │ 150 │
├─────────────────┼────────────┼───────┤
│ Sony │ Monitor │ 240 │
├─────────────────┼────────────┼───────┤
│ Creative Labs │ DVD drive │ 180 │
├─────────────────┼────────────┼───────┤
│ Creative Labs │ DVD burner │ 180 │
├─────────────────┼────────────┼───────┤
│ Hewlett Packard │ Printer │ 270 │
└─────────────────┴────────────┴───────┘
+++++> graph
read products.csv
│ read manufacturers.csv
├───────────────────────────────┘
join natural
│
print
│ read products.csv
│ │
│ project manid, price avg
│ │
│ select price_avg >= 150
│ │
│ print
│ │ read manufacturers.csv
│ ├───────────────────────────────┘
│ join natural
│ │
│ project manufacturer, price_avg
│ │
│ print
│ │ read average.csv
│ │ │
│ │ print
│ │ │ read products.csv
│ │ │ ├───────────────────────────────┐
│ │ │ │ dup
│ │ │ │ │
│ │ │ │ project price min
│ │ │ ├───────────────────────────────┘
│ │ │ join 1
│ │ │ │
│ │ │ select price = price_min
│ │ │ │
│ │ │ project name, price
│ │ │ │
│ │ │ print
│ │ │ │ read products.csv
│ │ │ │ │
│ │ │ │ project manid, price max
│ │ │ │ │ read products.csv
│ │ │ │ ├───────────────────────────────┘
│ │ │ │ join natural
│ │ │ │ │
│ │ │ │ select price = price_max
│ │ │ │ │ read manufacturers.csv
│ │ │ │ ├───────────────────────────────┘
│ │ │ │ join natural
│ │ │ │ │
│ │ │ │ project manufacturer, name, price
│ │ │ │ │
│ │ │ │ print
+++++> write example.rel
+++++> q
Bye!
MacBook-Pro:~ matti$ ./relation
Relation 1.0 © 2019 belle-nuit.com
> read example.rel
Select all the data from the products, including all the data for each product's manufacturer.
┌────────┬─────────────────┬───────┬───────┬─────────────────┐
│ itemid │ name │ price │ manid │ manufacturer │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 1 │ Hard drive │ 240 │ 5 │ Fujitsu │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 2 │ Memory │ 120 │ 6 │ Winchester │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 3 │ ZIP drive │ 150 │ 4 │ Iomega │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 4 │ Floppy disk │ 5 │ 6 │ Winchester │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 5 │ Monitor │ 240 │ 1 │ Sony │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 6 │ DVD drive │ 180 │ 2 │ Creative Labs │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 7 │ CD drive │ 90 │ 2 │ Creative Labs │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 8 │ Printer │ 270 │ 3 │ Hewlett Packard │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 9 │ Toner cartridge │ 66 │ 3 │ Hewlett Packard │
├────────┼─────────────────┼───────┼───────┼─────────────────┤
│ 10 │ DVD burner │ 180 │ 2 │ Creative Labs │
└────────┴─────────────────┴───────┴───────┴─────────────────┘
Select the average price of each manufacturer's products, showing only the manufacturer's code.
┌───────┬───────────┐
│ manid │ price_avg │
├───────┼───────────┤
│ 5 │ 240 │
├───────┼───────────┤
│ 4 │ 150 │
├───────┼───────────┤
│ 1 │ 240 │
├───────┼───────────┤
│ 2 │ 150 │
├───────┼───────────┤
│ 3 │ 168 │
└───────┴───────────┘
Select the average price of each manufacturer's products, showing the manufacturer's name.
┌─────────────────┬───────────┐
│ manufacturer │ price_avg │
├─────────────────┼───────────┤
│ Fujitsu │ 240 │
├─────────────────┼───────────┤
│ Iomega │ 150 │
├─────────────────┼───────────┤
│ Sony │ 240 │
├─────────────────┼───────────┤
│ Creative Labs │ 150 │
├─────────────────┼───────────┤
│ Hewlett Packard │ 168 │
└─────────────────┴───────────┘
┌─────────────────┬───────────┐
│ manufacturer │ price_avg │
├─────────────────┼───────────┤
│ Fujitsu │ 240 │
├─────────────────┼───────────┤
│ Iomega │ 150 │
├─────────────────┼───────────┤
│ Sony │ 240 │
├─────────────────┼───────────┤
│ Creative Labs │ 150 │
├─────────────────┼───────────┤
│ Hewlett Packard │ 168 │
└─────────────────┴───────────┘
Select the name and price of the cheapest product.
┌─────────────┬───────┐
│ name │ price │
├─────────────┼───────┤
│ Floppy disk │ 5 │
└─────────────┴───────┘
Select the name of each manufacturer along with the name and price of its most expensive product.
┌─────────────────┬────────────┬───────┐
│ manufacturer │ name │ price │
├─────────────────┼────────────┼───────┤
│ Fujitsu │ Hard drive │ 240 │
├─────────────────┼────────────┼───────┤
│ Winchester │ Memory │ 120 │
├─────────────────┼────────────┼───────┤
│ Iomega │ ZIP drive │ 150 │
├─────────────────┼────────────┼───────┤
│ Sony │ Monitor │ 240 │
├─────────────────┼────────────┼───────┤
│ Creative Labs │ DVD drive │ 180 │
├─────────────────┼────────────┼───────┤
│ Creative Labs │ DVD burner │ 180 │
├─────────────────┼────────────┼───────┤
│ Hewlett Packard │ Printer │ 270 │
└─────────────────┴────────────┴───────┘
+++++> history
1: // Select all the data from the products, including all the data for each product's manufacturer.
2: read products.csv
3: read manufacturers.csv
4: join natural
5: print
6: // Select the average price of each manufacturer's products, showing only the manufacturer's code.
7: read products.csv
8: project manid, price avg
9: select price_avg >= 150
10: print
11: // Select the average price of each manufacturer's products, showing the manufacturer's name.
12: read manufacturers.csv
13: join natural
14: project manufacturer, price_avg
15: print
16: write average.csv
17: read average.csv
18: print
19: // Select the name and price of the cheapest product.
20: read products.csv
21: dup
22: project price min
23: join 1
24: select price = price_min
25: project name, price
26: print
27: // Select the name of each manufacturer along with the name and price of its most expensive product.
28: read products.csv
29: project manid, price max
30: read products.csv
31: join natural
32: select price = price_max
33: read manufacturers.csv
34: join natural
35: project manufacturer, name, price
36: print
+++++> q
Bye!