Extension of SimpleDB, a lightweight SQL RDBMS that supports indexes, multi-tenancy, and transactions. Implemented as part of CS3223 Database Implementation project.
- OpenJDK 11 or higher
java --version # Java RE version should output >11
Eclipse is the recommended code editor.
For VS Code, the following VSC extensions are recommended (VSC will prompt to install these extentions on launch):
- vscjava.vscode-java-pack
- Ensure the
studentdbdirectory is created. Otherwise, runtest/CreateStudentDBscript. - Run
test/SimpleIJscript. - Database is running. Enter database commands in the command line.
NOTE: Should you run into issues, delete the
studentdbdirectory and repeat from step 1
Implementation is an extension of SimpleDB from Edward Sciore. Project is used solely for educational purpose.
Done in the CreateStudentDB2.java file
select sid, sname from student
select sid, sname from student where sid = 5
select sid, sname from student where sname > 'bob'
select sid, majorid from student where sid = 10
select sid, majorid from student where majorid = 20
select cid, title, deptid from course order by cid
select gradyear, sname, sid from student order by gradyear desc, sid desc
select yearoffered from section group by yearoffered
select yearoffered, courseid from section group by yearoffered, courseid
select avg(eid) from enroll
select avg(eid), min(studentid), sum(sectionid) from enroll
select studentid, count(eid) from enroll group by studentid
select prof, courseid, min(yearoffered), max(yearoffered) from section group by prof, courseid
select distinct yearoffered from section
select distinct majorid, gradyear from student
select gradyear, count(sid) from student where gradyear > 2020 and sname > 'bob' group by gradyear order by countofsid
select sid,studentid,grade from student,enroll where sid>studentid
select sid,studentid,sname, grade from enroll, student where sid=studentid
select sid,majorid,did from dept,student where majorid=did
Hash/Sort-merge/Nested-loop Join:
select sid,sname,dname,title,grade from student,dept,course,enroll where sid=studentid and deptid=did and majorid=did
Idx Join:
select sid,sname,did,title,grade from dept,course,enroll,student where sid=studentid and majorid=did and deptid=did
Following Postgres, there are 2 cases for ORDER BY:
-
If there is GROUP BY or DISTINCT then the sort fields must be found in the GROUP BY or DISTINCT field.
- Positive case:
select distinct sname from student order by snameselect sname from student group by sname order by sname - Error cases:
select distinct sname from student order by sidselect sname from student group by sname order by sid
- Positive case:
-
If there is no GROUP BY or DISTINCT then can sort on any field in the tables (beyond what is being projected).
select sname from student order by sid