rosscado / raceready

Created for toolchain: https://console.bluemix.net/devops/toolchains/0fc11092-0119-4ab8-a5f0-6cbf19d20e03?env_id=ibm%3Ayp%3Aeu-gb
0 stars 0 forks source link

Event persistence #17

Open rosscado opened 6 years ago

rosscado commented 6 years ago

Save resources to a backend database.

rosscado commented 6 years ago

Accomplishments so far:

rosscado commented 6 years ago

Single DB Instance

I only have a single Cloudant database instance available under the Lite/free plan. I have bound the instance to the staging space app, leaving it unavailable to the production app. For this reason production can't be started for now.

Implement Transient Functionality First

I am pausing completion of the persistence feature until I have more functional work done first, specifically implementing event APIs #2

rosscado commented 6 years ago

Entity Relationships

Our entity/resource documents will sometimes contain nested entities/resources that are best represented as their own documents, rather than embedded.

This article explains how to represent such a relationship in a Cloudant/CouchDB NoSQL database: https://wiki.apache.org/couchdb/EntityRelationship

Example (many:1 relationship)

Model:

---
_id: event_id
type: event
organising_club_id: club_id
---
_id: club_id
type: club

Client logic:

club = {'title': 'Little Club'}
club = db.create_document(club)
event = {'title': 'Big Race', 'organising_club_id': club['_id']}
event = db.create_document(event)

Views (1:many relationship)

No view is required for a 1:1 or many:1 relationship. Views are required for 1:many relationships.