Azure database - Schema design rules
15:09 02 Sep 2018

I have a simple "use case", imagine I wish to clone the Facebook application with Xamarin & Azure.

After reading this : https://learn.microsoft.com/en-us/azure/cosmos-db/social-media-apps

I noticed that I can store my datas into a set of collections/document (SQL API).

But when I have to handle millions of relationships, it does not work, I have to use a Graph API database !

So, for this I need to create a database on Azure, here is what I will do for now :

1 - One Cosmos DB database - with SQL API (Collection) with : a) A collection for user b) A collection for publication

2 - One Comos DB database - with Gremlin API (Graph) with : a) A graph to manage the relationships between a user and a publication (ie. user A like publication B)

So, the SQL API database will manage all the records, and the Gremlin one for all the complexes relationships.

So, I have a few questions: 1) Do I really need 2 unconnected database ? Or it is a bad design ? Because each time I add a user, I need to add a document in the collection, but also a vertex ! It is a double management !

2) When I insert a document into a collection, it generate an "id" with a GUID key automatically. Can I use this ID as a key for my vertices ?

Maybe a user and a publication can have the same GUID ? and so, in my graph I don't know if my vertices is a user or a publication ?

Is there another way to manage this ?

Thanks

azure azure-cosmosdb gremlin azure-cosmosdb-sqlapi