I decided to migrate my database from MySQL to Mongo because most of the time my data is not structured. And that allowed me features that were too complex in traditional SQL.
There is one problem that I am currently facing, and the approach to the traditional relational SQL model in NoSQL. I read many times that NoSQL is not intended for relationships. Do I need to add them as an array to a document with a relation?
Here is one of the situations that made me stuck. In SQL, I had a separate table for oauth access tokens, which have user_id, client_id, access_token, expire as its attributes. This was a 1-N relationship between user and access_token. How do I do this in NoSQL? By adding an oauth_tokens array field? If I do, how can I search for a marker in an array? How to request
search for a document where the _id is $user_id and there is an element with $token in the access_tokens array?
source share