Giter Club home page Giter Club logo

lab2's Introduction

COSC 404 - Database System Implementation
Lab 2 - MySQL vs. PostgreSQL - Indexing for Performance

This lab demonstrates the advantage of using indexes in MySQL and PostgreSQL.

Setup

The labs use Java, Docker, and GitHub. Follow the setup and installation instructions to get your computer setup for the labs.

Creating Indexes and Using EXPLAIN

You will repeat the same tasks for both PostgreSQL and MySQL. Expect to consult the online documentation for MySQL and PostgreSQL to help you do this assignment. Hint: Complete one of the databases first then copy the code to the other. There are only a few changes between the two.

The two classes you will write are IndexMySQL.java and IndexPostgreSQL.java. The test classes are TestIndexMySQL.java and TestIndexPostgreSQL.java respectively. You will fill in the methods requested (search for TODO). Marks for each method are below. You receive the marks if you pass the JUnit tests AND have followed the requirements asked in the question (including documentation and proper formatting).

  • +1 mark - Method connect() to make a connection to the database.
  • +1 mark - Method close() to close the connection to the database.
  • +1 mark - Method drop() to drop the table bench that we will be using.
  • +1 mark - Method create() to create a bench table with fields:
    • id - integer, must auto-increment
    • val1 - integer (starts at 1 and each record increases by 1)
    • val2 - integer (val1 % 10)
    • str1 - varchar(20) = "Test"+val1
  • +2 marks - Method insert() to add the records as described above. You must use PreparedStatements to get full marks.
  • +2 marks - Write the method addindex1() that creates a unique index called idxBenchVal1 on val1. It then runs an explain with the query: SELECT * FROM bench WHERE val1 = 500.
  • +2 marks - Write the method addindex2() that creates a index called idxBenchVal2Val1 on (val2,val1). It then runs an explain with the query: SELECT * FROM bench WHERE val2 = 0 and val1 > 100.
  • Bonus: +1 mark if determine how to make insert() faster than inserting just one row at a time

Total Marks: 10

Submission

The lab can be marked immediately by the professor or TA by showing the output of the JUnit tests and by a quick code review. Otherwise, submit the URL of your GitHub repository on Canvas. Make sure to commit and push your updates to GitHub.

MySQL References

PostgreSQL References

lab2's People

Contributors

rlawrenc avatar sirusw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.