AdamVig / GoCoApi

API Server for the GoCoStudent app.
https://gocostudent.adamvig.com/api
GNU General Public License v3.0
0 stars 0 forks source link

Change to MySQL #38

Open AdamVig opened 7 years ago

AdamVig commented 7 years ago

CouchDB leaves a lot to be desired. Its basic functionality is good, but it fails in two major areas:

  1. querying: map and reduce functions are a hassle compared to SQL
  2. space efficiency: since GoCo updates the database frequently, CouchDB takes up large amounts of storage with old revisions of documents

The advantage of CouchDB is quick and dirty data modelling. For example, it will be a challenge to convert the Highland Express data to a relational schema.

CouchDB is also a practical, if improper, solution for caching data. MySQL makes that much more difficult, so Etags and the Expires header should be used in place of a homegrown caching solution.

Using MySQL will make it easier to reduce data duplication. Instead of storing a number of requests for each endpoint and a total number of requests, the new schema can store just the number of requests per endpoint. A view can be created to sum the total number of requests for each user and the total number of requests for each endpoint.

A view can also be created to calculate the date and time of each user's last request based on a timestamp in the endpoint usage table.

A simple first attempt at a schema: image