henryliangt / psql

PostgreSql
0 stars 0 forks source link

neo4j Database Model #11

Open henryliangt opened 1 year ago

henryliangt commented 1 year ago

Please build Data:

henryliangt commented 1 year ago

The sample data set has two JSON files. The core.json file contains an array of objects. Each object represents a core unit. Each core unit has a code, a title and a credit point value. A candidate can choose any combination to satisfy the 72 credit point core units rule. Below is an example of a unit in core.json

{
"code": "MATH1001",
"title": "MATH 1A",
"credit_point": 6
}

The students.json file contains an array of objects. Each object represent a student. Each student object has the following five properties: • "name": this field stores the student’s name • "degree": this field stores the degree name • "completed": this field is of array type. It stores all units a student has completed. Each completed unit has the following fields: – "code": the code of the unit – "title": the title of the unit – "year": the year the student attempted the unit – "credit_point": the credit point of the unit – "institution": the institution the student attempted the unit. The field can take two values: “internal” means the unit is taken within this institution; “external” means the unit is taken in a different institution. A unit attempted as “internal” also has a "score" field to record the score the student achieved. A score below 50 means fail. • "enrolled": this field is of array type. It stores all units a student is currently enrolled in. Each unit in this array has the same five fields as those of a completed unit: "code","title","year","credit_point" and "institution"

Below is an example of a student object, showing two completed units and one enrolled unit.

{
"name": "Bob",
"degree": "Bachelor of Computer Science",
"completed": [
{
"code": "MATH1001",
"title": "MATH 1A",
"credit_point": 6,
"year": 2020,
"institution": "external"
},
{
"code": "INFO1001",
"title": "Programming 1A",
"credit_point": 6,
"year": 2021,
"score": 75,
"institution": "internal"
}],
"enrolled": [
{
"code": "COMP3100",
"title": "Computer Graphics",
"credit_point": 6,
"year": 2022,
"institution": "internal"
}]
}
henryliangt commented 1 year ago

You are asked to design a graph that can capture all information in the given data set. The graph should have at least some nodes representing units and others representing students. Your graph should also capture the relationships between units and students. The graph will be used to check various degree rules.

henryliangt commented 1 year ago

You are asked to prepare a custom browser guide to set up the graph and to implement a number of queries for rule checking. Your guide must contain the following slides:

henryliangt commented 1 year ago

• Slide one: Graph Building. In this slide, you should provide one or more queries to build a graph to represent units and student information by loading the data from the JSON files. The graph should be built in a database called “comp5338a4”.

henryliangt commented 1 year ago

• Slide two: Graph Inspection. In this slide, include one query each to print out the following information: – The number of core units. The expected count is 14 for the given data set. – The number of elective units in the graph. The expected count for the given data set is 8

henryliangt commented 1 year ago

• Slide three: In this slide, write a query to compute the annual average mark for each student. Return the result sorted by name and year. The annual average mark is the arithmetic average of the scores of all internal units attempted in a particular year. The expected output is name year aam "Alice" 2020 79.75 "Alice" 2021 79.5 "Bob" 2020 82.0 "Bob" 2021 65.0 "Bob" 2022 80.0 "Charlie" 2020 65.2 "Charlie" 2021 74.62499999999999

henryliangt commented 1 year ago

• Slide four: Total credit point rule. In this slide, write a query to compute the total credit points each student is expected to achieve after they successfully complete the units they are currently enrolled in. Return the name and expected total credit points for those whose expected total credit points will be greater than or equal to 144. The expected output is:

name total_cp "Alice" 144 "Charlie" 144

henryliangt commented 1 year ago

Slide five: Core unit rule. In this slide, write a query to check for each student in the graph, if he/she has obtained or will obtain 72 credit points from core units after they successfully complete the units they are currently enrolled in. The expected output is: name satisfy_core "Charlie" true "Bob" false "Alice" true

henryliangt commented 1 year ago

Slide six: COMP/INFO unit rule. In this slide, write a query to check for each student in the graph, if he/she has obtained or will obtain 102 credit point from COMP/INFO unit after they successfully complete the units they are currently enrolled in. The expected output is:

name satisfy_compinfo "Bob" false "Alice" false "Charlie" true

henryliangt commented 1 year ago

Slide seven: Elective Units. In this slide, write a query to list the code of all elective units a student has completed or is enrolled in. The expected output is:

name electives "Alice" ["DECO1001", "BUSS1001", "DECO1002", "BENG1001", "MATH2009", "PSYC1001"] "Bob" ["DECO1001", "MATH2U01", "PSYC1001"] "Charlie" ["BENG1001", "MATH2009", "MATH2U01", "BUSS2U01"]

henryliangt commented 1 year ago

Slide eight: External unit Rule. For each student who has completed or is currently enrolled in some external units, check if they satisfy the rule of maximum 72cp from external units. The expected output of the query is: name satisfy_ext "Bob" true "Charlie" true

henryliangt commented 1 year ago

Slide nine: Clear the Graph. In this slide write a query to delete all nodes and their relationships in the graph

henryliangt commented 1 year ago

The deliverable of this work is the browser guide file.

henryliangt commented 1 year ago

Please build a graph consisting of nodes representing units and students who have enrolled in or completed those units.

The degree of interest is a hypothetical three year Bachelor of Computer Science degree. Any unit that counts towards this degree has a unit code, a title and the credit points a student can obtain. The unit code consists of four letters and four digits. “COMP5338" is an example of a unit code. Units completed in other institutions can count towards the degree. These include units a candidate takes prior to enrolling in this degree and units a candidate takes as part of the exchange program. When there is no exact mapping, an unspecified unit would usually be given. An unspecified unit has a letter "U" in the numeric part of the code. “COMP1U01” is an example of an unspecified unit in the COMP area. The degree has the following requirements:

A candidate must complete 144 credit points;

A candidate must complete 72 credit points from core units;

A candidate must complete at least 102 credit points from units whose code starts with COMP or INFO;

A candidate can complete up to 30 credit points from elective units. Any unit whose code begins with anything other than COMP or INFO and is not listed as a core unit counts as an elective unit.

A candidate can have at most 72 credit points that are taken from other institutions counting towards the degree. A unit taken in another institution may be mapped to a core unit, a COMP/INFO unit, an elective unit or an unspecified unit. An unspec�ified unit can count towards different collections based on the code. For example, “COMP1U01” counts as a COMP unit. It can be used to satisfy rule 3

Data: data.zip