Csc 8711, Databases and the Web - Project 6

Due: Monday, April 29th (STRICT DEADLINE)

These two programs will constitute 50% of your final exam. The other 50% will be from a take home problem set given to you on April 26th. All programs and problems for the final exam are due April 29th by Midnight - STRICT DEADLINE!!!

Neo4J Graph Database

I. BILL OF MATERIALS

Consider the Neo4J database loaded in loadParts.py. Run this program to create the graph database. Then, write a program to compute cost of parts as well as basic subparts of parts. A sample run is given below:
macbook-pro:bom raj$ python3 BOM.py raj 1raj23

(c) cost of part
(s) sub-parts
(q) quit

What do you want to see: c
Enter part name: engine
Cost of engine is 744.0

(c) cost of part
(s) sub-parts
(q) quit

What do you want to see: c
Enter part name: cylinder
Cost of cylinder is 29.0

(c) cost of part
(s) sub-parts
(q) quit

What do you want to see: s
Enter part name: engine
Subparts of pname: 

bolt 192
screw 136
gasket 16
sparkplug 4


(c) cost of part
(s) sub-parts
(q) quit

What do you want to see: s
Enter part name: cylinder
Subparts of pname: 

bolt 4
screw 6
gasket 3


(c) cost of part
(s) sub-parts
(q) quit

What do you want to see: q
macbook-pro:bom raj$
Note: loadData.py is an example of a program that creates one instance of the database; Your solution should work on any other graph data set that could be loaded by a similar program; i.e. the Node and Relationship types will be the same, but instances of Nodes and Relationships may be different.

II. BASEBALL STANDINGS

Consider the following data describing baseball teams and results of games:
macbook-pro:baseball raj$ more teams.dat 
Braves:Atlanta:ATL
Cardinals:Saint Louis:STL
Cubs:Chicago:CHC
Diamondbacks:Arizona:ARI
Indians:Cleveland:CLE

macbook-pro:baseball raj$ more games.dat
2004-03-20:ARI:CHC:10:11
2004-03-23:ATL:STL:0:1
2004-03-27:STL:CHC:7:9
2004-03-27:CLE:ATL:1:0
2004-03-30:ATL:CHC:10:5
2004-04-01:CLE:ARI:8:8
2004-04-15:ARI:ATL:3:11
2004-04-17:CLE:STL:7:11
2004-04-20:STL:ARI:10:12
2004-04-22:CHC:CLE:7:4
2004-04-24:CHC:ARI:7:12
2004-04-29:STL:ATL:2:10
2004-05-01:ATL:CLE:14:14
2004-05-01:CHC:STL:10:0
2004-05-04:CHC:ATL:10:8
2004-05-04:ARI:CLE:8:7
2004-05-08:ATL:ARI:6:8
2004-05-13:STL:CLE:3:6
2004-05-15:ARI:STL:7:13
2004-05-15:CLE:CHC:6:8
2004-05-18:ARI:CHC:13:5
2004-05-22:ATL:STL:3:6
Rows in teams.dat contain team name, team location, and team code, whereas rows in games.dat contain game date, visiting team code, home team code, visiting team score, and home team score.
  1. Write a Python program (loadData.py) to load this data in a Neo4J database. The run of this program should look like below:
    macbook-pro:baseball raj$ python3 loadData.py raj 1raj23
    Data loaded!
    macbook-pro:baseball raj$
    
    You may assume that teams.dat and games.dat are available in the current directory where loadData.py is located. You will create "Team" nodes and two directional "game" Relationships between each of the two teams in a game. Please delete all data before you load!

  2. Write a Python program (BB.py) that produces "standings" as well as "team results". A Sample run is given below:
    MacBook-Pro:baseball raj$ python3 BB.py raj 1raj23
    
    (s) standings
    (t) team results
    (q) quit
    
    What do you want to see: s
    
    TEAM                   WINS LOSSES   TIES PERCENT
    -------------------- ------ ------ ------ -------
    Cubs                      6      3      0   0.667
    Diamondbacks              5      3      1   0.611
    Cardinals                 4      5      0   0.444
    Braves                    3      5      1   0.389
    Indians                   2      4      2   0.375
    
    (s) standings
    (t) team results
    (q) quit
    
    What do you want to see: t
    Enter team code (e.g. ARI, ATL, CHC, CLE, STL): ATL
    
    Atlanta Braves
    
          DATE             OPPONENT    US  THEM RESULT
    2004-03-23         at Cardinals     0     1   LOSS
    2004-03-27              Indians     0     1   LOSS
    2004-03-30              at Cubs    10     5    WIN
    2004-04-15         Diamondbacks    11     3    WIN
    2004-04-29            Cardinals    10     2    WIN
    2004-05-01           at Indians    14    14    TIE
    2004-05-04                 Cubs     8    10   LOSS
    2004-05-08      at Diamondbacks     6     8   LOSS
    2004-05-22         at Cardinals     3     6   LOSS
    
    Overall Record:  3-5-1
    
    
    (s) standings
    (t) team results
    (q) quit
    
    What do you want to see: t
    Enter team code (e.g. ARI, ATL, CHC, CLE, STL): AAA
    
    Invalid Code
    
    (s) standings
    (t) team results
    (q) quit
    
    What do you want to see: q
    MacBook-Pro:baseball raj$