-1

how to make relation for no sql database?

You can say it for firebase database, where database is in json format.

Community
  • 1
  • 1
Somnath
  • 368
  • 2
  • 9
  • 22
  • what do you mean by "relation"? Like, joins? – Shinra tensei Sep 06 '17 at 08:53
  • I want to create relation for a chat application. – Somnath Sep 06 '17 at 08:54
  • Now I'm completely lost. You just made your question totally unintelligible. – Shinra tensei Sep 06 '17 at 08:55
  • 1
    I think he wanted to use the word *relation* in the case when we use it for *table*... – campovski Sep 06 '17 at 08:56
  • Or foreign key. – JMedinilla Sep 06 '17 at 08:57
  • if it was that I could understand it, but it's still too broad and unclear. – Shinra tensei Sep 06 '17 at 08:58
  • @campovski you are right – Somnath Sep 06 '17 at 09:01
  • @Shinratensei may be you are new i am also that why it is uncleared for you. But i think it is possible. – Somnath Sep 06 '17 at 09:05
  • Possible duplicate of [Structure a NoSQL database for a chat application (using FireBase)](https://stackoverflow.com/questions/35969715/structure-a-nosql-database-for-a-chat-application-using-firebase) – campovski Sep 06 '17 at 09:10
  • @Somnath I'm not new in stackoverflow or programming, that's why I'm telling you it's unclear what you want, because unclear questions end up being closed. Please think of what you want to do, try to do it and come back with a clear question asking about a problem you're having, not a 10 words question about how to make nosql relational. Of course it is possible, if that answers your question, but you have to try to do it. – Shinra tensei Sep 06 '17 at 09:11

2 Answers2

1

A NO SQL database means that database has no relations. Either go with SQL database and convert JSON format or face the truth that in NOSQL there are no relations.

campovski
  • 2,979
  • 19
  • 38
0

Before anything, I will give you an example of how to try to do this, but I want to tell you that I wouldn't actually do this again. Firebase is no good replace for MySQL.

Making relations for a noSQL database is not possible, but you could always make them "manually" and decide how to work with it.

What I meant with "manually" is that you can duplicate data for that, but that's not a very good option. For example, I made long ago an Android app to manage neightbour communities, and because of the time I had to do it I decided to make it with Firebase.

And I will never do it again, to be honest. I didn't want to lose time on an API, but I lost it anyway trying to structure everything nicely and with all the changes I had to make every 2 days so everything wouldn't fail.

Here you have an example. The database has 2 nodes, the communities and the users.

enter image description here

The users have these fields:

enter image description here

And, meanwhile, the communities have an incidences list, and those store the email of its author as any other field (image not relatable, they are random ones).

enter image description here

So, TLDR: No, you can't make relations. The only way to do what you want is with duplicated data, like the email of its author on the incidence.

PS: I made a chat app with Firebase in my company, I would share the DB with you so you can see the structure, but it's confidential, you know.

JMedinilla
  • 481
  • 5
  • 15