I’ve been building some sort of webb app using new approaches to it. Now, I just want to rewrite db into nosql. and have some question upon it.
For instanse, i had users, languages, dictionary – they were linked:
`SQL> create table users
2 (user_id number constraint pk_users primary key,
3 username varchar2(30) not null
4 );
Table created.
SQL> create table languages
2 (language_id number constraint pk_lang primary key,
3 language_name varchar2(30) not null
4 );
Table created.
SQL> create table dictionary
2 (dict_id number constraint pk_dict primary key,
3 user_id number constraint fk_dict_user references users (user_id),
4 language_id number constraint fk_dict_lang references languages (language_id),
5 —
6 original_word varchar2(30) not null,
7 original_trasncriptioned_word varchar2(30) not null,
8 translated_word varchar2(30) not null
9 );
Table created.`
I had three separated projects been communicate with each other by rabbitmq.
Now, i can not understand how it is represented into nosql db. Is this format correct?
{
"users": [
{
"user_id": 1,
"username": "user1"
},
{
"user_id": 2,
"username": "user2"
},
...
],
"languages": [
{
"language_id": 1,
"language_name": "English"
},
{
"language_id": 2,
"language_name": "Spanish"
},
...
],
"dictionary": [
{
"dict_id": 1,
"user_id": 1,
"language_id": 1,
"original_word": "hello",
"original_transcriptioned_word": "hɛˈloʊ",
"translated_word": "hola"
},
{
"dict_id": 2,
"user_id": 2,
"language_id": 2,
"original_word": "hola",
"original_transcriptioned_word": null,
"translated_word": "hello"
},
...
]
}
I’m strunggling with “architecture” of it. Should i have also three separated project as I had with Sql db.
If so, how am i able to link dictionary.user_id or dictionary.language_id with according tables?
public class Dictionary : Entity
{
public string Id { get; set; }
public string Name { get; set; }
public string LanguageId { get; set; }
public Dictionary() : base(true)
{
}
}
public class Entity
{
[JsonPropertyName("id")]
public string Id { get; set; }
[JsonPropertyName("ttl")]
public int Ttl { get; set; }
public Entity(bool generateId = true)
{
SetDefaultTimeToLive();
if (generateId)
{
this.Id = Guid.NewGuid().ToString();
}
}
public virtual void SetDefaultTimeToLive()
{
Ttl = -1;
}
}
Could you please give me some hint or any pieces of advice?