Need solution in KOTLIN and SQL. Task: There are 4 subtasks where we have to take input from database, process the data
Posted: Sun Jul 10, 2022 11:29 am
Need solution in KOTLIN and SQL.
Task: There are 4 subtasks where we have to take input fromdatabase, process the data and result the output usingKotlin.
The input should be taken from "input.db". This databasecontains 5 tables. Tables structure is given in SQL queries asshown in figure.
Data should be processed for conditions as in four subtasks.
Subtasks:
1.Generate an array linking each student with:• its average grade (from all courses),• its grade at all attended courses (passed ones and failedones)
2.Generate an array linking each student with:• its average grade (from all courses),• its grade at all attended courses (passed ones and failedones),• its possibility to apply to each course provided by University(Univ do they meets requirements for each course). Coursesthat the student has already attended should not be present, evenif failed.
3.Generate an array linking each course (identified by coursecode) to the list of applicants who meet the minimum requirementsand have applied to this course, identified by their name.
4.Using the previous task answer, generate the same output butthis time take into account that some courses have limitedavailable seats. This should give you the final affectation list toUniversity needs!
CREATE TABLE IF NOT EXISTS Course ( id INTEGER, - Course unique id name TEXT, -- Course name c.g. 'Maths 1' code TEXT UNIQUE, -- Course code e.g. 'MA001' study_year INTEGER, -- Study year, e.g. '1', '2', etc available seats INTEGER,-- Available seats, nullable if not limit PRIMARY KEY(id) ); CREATE TABLE IF NOT EXISTS Student ( id INTEGER, - Student unique id name TEXT UNIQUE, -- Student name e.g. 'Jane Doe' merit_points INTEGER, -- Merit points e.g. '71' PRIMARY KEY(id) ); CREATE TABLE IF NOT EXISTS Course Requirement ( id INTEGER, course_id INTEGER, - id of the course that has requirements required_course_id INTEGER, -- id of one of the required courses minimum grade INTEGER, -- Minimum grade to fulfill requirement, '51' if null FOREIGN KEY(course_id) REFERENCES Course(id), FOREIGN KEY(required_course_id) REFERENCES Course(id), PRIMARY KEY(id) ); CREATE TABLE IF NOT EXISTS Student Course Application ( id INTEGER, course_id INTEGER, -- Course id that is applied to by student student_id INTEGER, -- Student id applying to course FOREIGN KEY(course_id) REFERENCES Course(id), FOREIGN KEY(student_id) REFERENCES Student(id), PRIMARY KEY(id) ); CREATE TABLE IF NOT EXISTS StudentCourseExamRecord ( id INTEGER, course_id INTEGER, -- Course id for which student got a grade student id INTEGER, -- Student id grade_obtained INTEGER, -- Grade obtained (max: 100, passing: 51) FOREIGN KEY(course_id) REFERENCES Course(id), FOREIGN KEY(student_id) REFERENCES Student(id), PRIMARY KEY(id) );
Task: There are 4 subtasks where we have to take input fromdatabase, process the data and result the output usingKotlin.
The input should be taken from "input.db". This databasecontains 5 tables. Tables structure is given in SQL queries asshown in figure.
Data should be processed for conditions as in four subtasks.
Subtasks:
1.Generate an array linking each student with:• its average grade (from all courses),• its grade at all attended courses (passed ones and failedones)
2.Generate an array linking each student with:• its average grade (from all courses),• its grade at all attended courses (passed ones and failedones),• its possibility to apply to each course provided by University(Univ do they meets requirements for each course). Coursesthat the student has already attended should not be present, evenif failed.
3.Generate an array linking each course (identified by coursecode) to the list of applicants who meet the minimum requirementsand have applied to this course, identified by their name.
4.Using the previous task answer, generate the same output butthis time take into account that some courses have limitedavailable seats. This should give you the final affectation list toUniversity needs!
CREATE TABLE IF NOT EXISTS Course ( id INTEGER, - Course unique id name TEXT, -- Course name c.g. 'Maths 1' code TEXT UNIQUE, -- Course code e.g. 'MA001' study_year INTEGER, -- Study year, e.g. '1', '2', etc available seats INTEGER,-- Available seats, nullable if not limit PRIMARY KEY(id) ); CREATE TABLE IF NOT EXISTS Student ( id INTEGER, - Student unique id name TEXT UNIQUE, -- Student name e.g. 'Jane Doe' merit_points INTEGER, -- Merit points e.g. '71' PRIMARY KEY(id) ); CREATE TABLE IF NOT EXISTS Course Requirement ( id INTEGER, course_id INTEGER, - id of the course that has requirements required_course_id INTEGER, -- id of one of the required courses minimum grade INTEGER, -- Minimum grade to fulfill requirement, '51' if null FOREIGN KEY(course_id) REFERENCES Course(id), FOREIGN KEY(required_course_id) REFERENCES Course(id), PRIMARY KEY(id) ); CREATE TABLE IF NOT EXISTS Student Course Application ( id INTEGER, course_id INTEGER, -- Course id that is applied to by student student_id INTEGER, -- Student id applying to course FOREIGN KEY(course_id) REFERENCES Course(id), FOREIGN KEY(student_id) REFERENCES Student(id), PRIMARY KEY(id) ); CREATE TABLE IF NOT EXISTS StudentCourseExamRecord ( id INTEGER, course_id INTEGER, -- Course id for which student got a grade student id INTEGER, -- Student id grade_obtained INTEGER, -- Grade obtained (max: 100, passing: 51) FOREIGN KEY(course_id) REFERENCES Course(id), FOREIGN KEY(student_id) REFERENCES Student(id), PRIMARY KEY(id) );