Sitemap
Will Jones

Will Jones

Former pres @UCLEntrepreneur | CS @Cambridge_Uni, Fellow @ASIDataScience | Mathematical Genomics @emblebi | open science, genomics, data security.

Object Relational Models (ORM)

2 min readMay 30, 2017

As part of building Heterogeneous as was described in my previous post, I am building the backend of the website. This has proven a steep learning curve, and while we have a functioning demo it is not imperative to improve the quality and robustness of the platform.

One of the ways to do that, is to use what is known as an Object Relational Model or (ORM) for sure in order to store data. We are storing user login information but also genotypes with MongoDB — a extremely flexible noSQL database. A MongoDB database consists of collections which comprise key-value pairs. This is a fantastically flexible database design because it essentially translates to ‘there are no rules’.

A concrete example, suppose we wanted to store information pertaining to users on our platform. We can store data in the following format:

{“_id”: ID, ”email”: email, “password”: password, “email_confirmed”: boolean}

This is is a perfectly reasonable, if simple, set of data to store user information. (Obviously we use salted hashes of the user password...)

Get Will Jones’s stories in your inbox

Join Medium for free to get updates from this writer.

However, there is nothing preventing us from adding something else when we save this user. For example.

{“_id”: ID, ”email”: email, “password”: password, “email_confirmed”: boolean, "random_field": "something stupid"}

Without a proper ORM, there is nothing to prevent me from storing this as a valid user. This example actually would not cause a problem, but what if I accidentally stored a user without an email? This would cause a problem when the application tries to send a welcome email. It is best to ensure that when something is saved to a database, it takes the form you expect.

MongoKit is such an engine, that we have decided to use.

--

--

Will Jones
Will Jones

Written by Will Jones

Former pres @UCLEntrepreneur | CS @Cambridge_Uni, Fellow @ASIDataScience | Mathematical Genomics @emblebi | open science, genomics, data security.