fetching data from 2 collections in firebase












-1















I have below mentioned db structure where users master data is saving in users collection and images is saving in users_slug collection, I am saving users collection node key as a reference in users_slug collection So basically I will have one master collection and many child collections so I need to get all the child's data based on masters table records node key (basically one to many relationship) where I can perform CRUD operation on child table based on masters node key.



I have 2 queries ....



1) Below mentioned db structure is good approach or not? (Because I am new to firebase, and I searched a lot but didn't find anything related to it )



2) How can I perform fetch on both the collection based on node key ?



{
"users": {
"-LSDmLO1GyfbumPZPopb": {
"first_name": "test",
"gender": "M",
"last_name": "test123",
"username": "test123"
}
},
"users_slug": {
"-LSDmLgLW9KgTg1BpsxX": [
{
"new_file_name": "5bfb97e92dbde.jpg",
"original_file_name": "128483.1.jpg",
"user_id": "-LSDmLO1GyfbumPZPopb"
},
{
"new_file_name": "5bfb97e92dd09.jpg",
"original_file_name": "amit.jpg",
"user_id": "-LSDmLO1GyfbumPZPopb"
},
{
"new_file_name": "5bfb97e92dd45.jpeg",
"original_file_name": "download.jpeg",
"user_id": "-LSDmLO1GyfbumPZPopb"
}
]
}
}









share|improve this question

























  • Could you give more info on which exact queries you want to be able to execute. This has an influence on your NoSQL data model. For example, if you want to query all the image related to a user you denormalize your data in such a way you would be able to do it in one query.

    – Renaud Tarnec
    Nov 26 '18 at 10:50













  • @RenaudTarnec i have updated my question and tried to brief the doubt.

    – Vivek Singh
    Nov 26 '18 at 11:05


















-1















I have below mentioned db structure where users master data is saving in users collection and images is saving in users_slug collection, I am saving users collection node key as a reference in users_slug collection So basically I will have one master collection and many child collections so I need to get all the child's data based on masters table records node key (basically one to many relationship) where I can perform CRUD operation on child table based on masters node key.



I have 2 queries ....



1) Below mentioned db structure is good approach or not? (Because I am new to firebase, and I searched a lot but didn't find anything related to it )



2) How can I perform fetch on both the collection based on node key ?



{
"users": {
"-LSDmLO1GyfbumPZPopb": {
"first_name": "test",
"gender": "M",
"last_name": "test123",
"username": "test123"
}
},
"users_slug": {
"-LSDmLgLW9KgTg1BpsxX": [
{
"new_file_name": "5bfb97e92dbde.jpg",
"original_file_name": "128483.1.jpg",
"user_id": "-LSDmLO1GyfbumPZPopb"
},
{
"new_file_name": "5bfb97e92dd09.jpg",
"original_file_name": "amit.jpg",
"user_id": "-LSDmLO1GyfbumPZPopb"
},
{
"new_file_name": "5bfb97e92dd45.jpeg",
"original_file_name": "download.jpeg",
"user_id": "-LSDmLO1GyfbumPZPopb"
}
]
}
}









share|improve this question

























  • Could you give more info on which exact queries you want to be able to execute. This has an influence on your NoSQL data model. For example, if you want to query all the image related to a user you denormalize your data in such a way you would be able to do it in one query.

    – Renaud Tarnec
    Nov 26 '18 at 10:50













  • @RenaudTarnec i have updated my question and tried to brief the doubt.

    – Vivek Singh
    Nov 26 '18 at 11:05
















-1












-1








-1








I have below mentioned db structure where users master data is saving in users collection and images is saving in users_slug collection, I am saving users collection node key as a reference in users_slug collection So basically I will have one master collection and many child collections so I need to get all the child's data based on masters table records node key (basically one to many relationship) where I can perform CRUD operation on child table based on masters node key.



I have 2 queries ....



1) Below mentioned db structure is good approach or not? (Because I am new to firebase, and I searched a lot but didn't find anything related to it )



2) How can I perform fetch on both the collection based on node key ?



{
"users": {
"-LSDmLO1GyfbumPZPopb": {
"first_name": "test",
"gender": "M",
"last_name": "test123",
"username": "test123"
}
},
"users_slug": {
"-LSDmLgLW9KgTg1BpsxX": [
{
"new_file_name": "5bfb97e92dbde.jpg",
"original_file_name": "128483.1.jpg",
"user_id": "-LSDmLO1GyfbumPZPopb"
},
{
"new_file_name": "5bfb97e92dd09.jpg",
"original_file_name": "amit.jpg",
"user_id": "-LSDmLO1GyfbumPZPopb"
},
{
"new_file_name": "5bfb97e92dd45.jpeg",
"original_file_name": "download.jpeg",
"user_id": "-LSDmLO1GyfbumPZPopb"
}
]
}
}









share|improve this question
















I have below mentioned db structure where users master data is saving in users collection and images is saving in users_slug collection, I am saving users collection node key as a reference in users_slug collection So basically I will have one master collection and many child collections so I need to get all the child's data based on masters table records node key (basically one to many relationship) where I can perform CRUD operation on child table based on masters node key.



I have 2 queries ....



1) Below mentioned db structure is good approach or not? (Because I am new to firebase, and I searched a lot but didn't find anything related to it )



2) How can I perform fetch on both the collection based on node key ?



{
"users": {
"-LSDmLO1GyfbumPZPopb": {
"first_name": "test",
"gender": "M",
"last_name": "test123",
"username": "test123"
}
},
"users_slug": {
"-LSDmLgLW9KgTg1BpsxX": [
{
"new_file_name": "5bfb97e92dbde.jpg",
"original_file_name": "128483.1.jpg",
"user_id": "-LSDmLO1GyfbumPZPopb"
},
{
"new_file_name": "5bfb97e92dd09.jpg",
"original_file_name": "amit.jpg",
"user_id": "-LSDmLO1GyfbumPZPopb"
},
{
"new_file_name": "5bfb97e92dd45.jpeg",
"original_file_name": "download.jpeg",
"user_id": "-LSDmLO1GyfbumPZPopb"
}
]
}
}






firebase firebase-realtime-database






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 11:08







Vivek Singh

















asked Nov 26 '18 at 8:37









Vivek SinghVivek Singh

2,3301921




2,3301921













  • Could you give more info on which exact queries you want to be able to execute. This has an influence on your NoSQL data model. For example, if you want to query all the image related to a user you denormalize your data in such a way you would be able to do it in one query.

    – Renaud Tarnec
    Nov 26 '18 at 10:50













  • @RenaudTarnec i have updated my question and tried to brief the doubt.

    – Vivek Singh
    Nov 26 '18 at 11:05





















  • Could you give more info on which exact queries you want to be able to execute. This has an influence on your NoSQL data model. For example, if you want to query all the image related to a user you denormalize your data in such a way you would be able to do it in one query.

    – Renaud Tarnec
    Nov 26 '18 at 10:50













  • @RenaudTarnec i have updated my question and tried to brief the doubt.

    – Vivek Singh
    Nov 26 '18 at 11:05



















Could you give more info on which exact queries you want to be able to execute. This has an influence on your NoSQL data model. For example, if you want to query all the image related to a user you denormalize your data in such a way you would be able to do it in one query.

– Renaud Tarnec
Nov 26 '18 at 10:50







Could you give more info on which exact queries you want to be able to execute. This has an influence on your NoSQL data model. For example, if you want to query all the image related to a user you denormalize your data in such a way you would be able to do it in one query.

– Renaud Tarnec
Nov 26 '18 at 10:50















@RenaudTarnec i have updated my question and tried to brief the doubt.

– Vivek Singh
Nov 26 '18 at 11:05







@RenaudTarnec i have updated my question and tried to brief the doubt.

– Vivek Singh
Nov 26 '18 at 11:05














1 Answer
1






active

oldest

votes


















1














(If I understand correctly your needs) you could denormalize your data like the following, by duplicating the slug data of each user under each user node.



This way you only need one query to get all the "slugs" of a given user.



You may keep the users_slug node (i.e. "collection" to use the vocabulary of your post) if you need to make some specific queries. (For example queries to the -LSDmLgLW9KgTg1BpsxX node -or to future siblings-, but it is not clear what is this uniqueId).



Denormalizing is quite common in NoSQL world and you should not hesitate to duplicate your data, in order to optimize your queries. Note that to simultaneously write to two (or more) nodes, in order to manage data consistency, you can use the update() method, see the docs here and here.



{
"users": {
"-LSDmLO1GyfbumPZPopb": {
"first_name": "test",
"gender": "M",
"last_name": "test123",
"username": "test123"
"slugs": {
"-LSDmLgLW9KgTg1BpsxX": [
{
"new_file_name": "5bfb97e92dbde.jpg",
"original_file_name": "128483.1.jpg"
},
{
"new_file_name": "5bfb97e92dd09.jpg",
"original_file_name": "amit.jpg"
},
....
]

}
},
"users_slug": {
"-LSDmLgLW9KgTg1BpsxX": [
{
"new_file_name": "5bfb97e92dbde.jpg",
"original_file_name": "128483.1.jpg",
"user_id": "-LSDmLO1GyfbumPZPopb"
},
..........
]
}
}


Finally, you may watch this official Firebase video series about "The Firebase Database For SQL Developers" https://www.youtube.com/playlist?list=PLl-K7zZEsYLlP-k-RKFa7RyNPa9_wCH2s and in particular the 6th video on denormalization https://www.youtube.com/watch?v=vKqXSZLLnHA&index=7&list=PLl-K7zZEsYLlP-k-RKFa7RyNPa9_wCH2s&t=0s






share|improve this answer


























  • how to I fetch data from this collection by '-LSEufUsgTiWMESbAZfO' ID? Array ( [-LSEufnnC_fTx1svGGv8] => Array ( [slug_node_key] => -LSEufdEJ_d4ZhnqbUJA [user_node_key] => -LSEufUsgTiWMESbAZfO ) )

    – Vivek Singh
    Nov 26 '18 at 12:17











  • I am not sure to understand what you mean. You may be more precise on which exact queries you want to execute, independently of the initial data model. E.g. all users with a certain slug? all slugs for a user? etc.

    – Renaud Tarnec
    Nov 26 '18 at 15:58













  • i just want to filter data from 2 collection based on node key which is primary key in one collection and reference key in another collection

    – Vivek Singh
    Nov 28 '18 at 4:26











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53477301%2ffetching-data-from-2-collections-in-firebase%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














(If I understand correctly your needs) you could denormalize your data like the following, by duplicating the slug data of each user under each user node.



This way you only need one query to get all the "slugs" of a given user.



You may keep the users_slug node (i.e. "collection" to use the vocabulary of your post) if you need to make some specific queries. (For example queries to the -LSDmLgLW9KgTg1BpsxX node -or to future siblings-, but it is not clear what is this uniqueId).



Denormalizing is quite common in NoSQL world and you should not hesitate to duplicate your data, in order to optimize your queries. Note that to simultaneously write to two (or more) nodes, in order to manage data consistency, you can use the update() method, see the docs here and here.



{
"users": {
"-LSDmLO1GyfbumPZPopb": {
"first_name": "test",
"gender": "M",
"last_name": "test123",
"username": "test123"
"slugs": {
"-LSDmLgLW9KgTg1BpsxX": [
{
"new_file_name": "5bfb97e92dbde.jpg",
"original_file_name": "128483.1.jpg"
},
{
"new_file_name": "5bfb97e92dd09.jpg",
"original_file_name": "amit.jpg"
},
....
]

}
},
"users_slug": {
"-LSDmLgLW9KgTg1BpsxX": [
{
"new_file_name": "5bfb97e92dbde.jpg",
"original_file_name": "128483.1.jpg",
"user_id": "-LSDmLO1GyfbumPZPopb"
},
..........
]
}
}


Finally, you may watch this official Firebase video series about "The Firebase Database For SQL Developers" https://www.youtube.com/playlist?list=PLl-K7zZEsYLlP-k-RKFa7RyNPa9_wCH2s and in particular the 6th video on denormalization https://www.youtube.com/watch?v=vKqXSZLLnHA&index=7&list=PLl-K7zZEsYLlP-k-RKFa7RyNPa9_wCH2s&t=0s






share|improve this answer


























  • how to I fetch data from this collection by '-LSEufUsgTiWMESbAZfO' ID? Array ( [-LSEufnnC_fTx1svGGv8] => Array ( [slug_node_key] => -LSEufdEJ_d4ZhnqbUJA [user_node_key] => -LSEufUsgTiWMESbAZfO ) )

    – Vivek Singh
    Nov 26 '18 at 12:17











  • I am not sure to understand what you mean. You may be more precise on which exact queries you want to execute, independently of the initial data model. E.g. all users with a certain slug? all slugs for a user? etc.

    – Renaud Tarnec
    Nov 26 '18 at 15:58













  • i just want to filter data from 2 collection based on node key which is primary key in one collection and reference key in another collection

    – Vivek Singh
    Nov 28 '18 at 4:26
















1














(If I understand correctly your needs) you could denormalize your data like the following, by duplicating the slug data of each user under each user node.



This way you only need one query to get all the "slugs" of a given user.



You may keep the users_slug node (i.e. "collection" to use the vocabulary of your post) if you need to make some specific queries. (For example queries to the -LSDmLgLW9KgTg1BpsxX node -or to future siblings-, but it is not clear what is this uniqueId).



Denormalizing is quite common in NoSQL world and you should not hesitate to duplicate your data, in order to optimize your queries. Note that to simultaneously write to two (or more) nodes, in order to manage data consistency, you can use the update() method, see the docs here and here.



{
"users": {
"-LSDmLO1GyfbumPZPopb": {
"first_name": "test",
"gender": "M",
"last_name": "test123",
"username": "test123"
"slugs": {
"-LSDmLgLW9KgTg1BpsxX": [
{
"new_file_name": "5bfb97e92dbde.jpg",
"original_file_name": "128483.1.jpg"
},
{
"new_file_name": "5bfb97e92dd09.jpg",
"original_file_name": "amit.jpg"
},
....
]

}
},
"users_slug": {
"-LSDmLgLW9KgTg1BpsxX": [
{
"new_file_name": "5bfb97e92dbde.jpg",
"original_file_name": "128483.1.jpg",
"user_id": "-LSDmLO1GyfbumPZPopb"
},
..........
]
}
}


Finally, you may watch this official Firebase video series about "The Firebase Database For SQL Developers" https://www.youtube.com/playlist?list=PLl-K7zZEsYLlP-k-RKFa7RyNPa9_wCH2s and in particular the 6th video on denormalization https://www.youtube.com/watch?v=vKqXSZLLnHA&index=7&list=PLl-K7zZEsYLlP-k-RKFa7RyNPa9_wCH2s&t=0s






share|improve this answer


























  • how to I fetch data from this collection by '-LSEufUsgTiWMESbAZfO' ID? Array ( [-LSEufnnC_fTx1svGGv8] => Array ( [slug_node_key] => -LSEufdEJ_d4ZhnqbUJA [user_node_key] => -LSEufUsgTiWMESbAZfO ) )

    – Vivek Singh
    Nov 26 '18 at 12:17











  • I am not sure to understand what you mean. You may be more precise on which exact queries you want to execute, independently of the initial data model. E.g. all users with a certain slug? all slugs for a user? etc.

    – Renaud Tarnec
    Nov 26 '18 at 15:58













  • i just want to filter data from 2 collection based on node key which is primary key in one collection and reference key in another collection

    – Vivek Singh
    Nov 28 '18 at 4:26














1












1








1







(If I understand correctly your needs) you could denormalize your data like the following, by duplicating the slug data of each user under each user node.



This way you only need one query to get all the "slugs" of a given user.



You may keep the users_slug node (i.e. "collection" to use the vocabulary of your post) if you need to make some specific queries. (For example queries to the -LSDmLgLW9KgTg1BpsxX node -or to future siblings-, but it is not clear what is this uniqueId).



Denormalizing is quite common in NoSQL world and you should not hesitate to duplicate your data, in order to optimize your queries. Note that to simultaneously write to two (or more) nodes, in order to manage data consistency, you can use the update() method, see the docs here and here.



{
"users": {
"-LSDmLO1GyfbumPZPopb": {
"first_name": "test",
"gender": "M",
"last_name": "test123",
"username": "test123"
"slugs": {
"-LSDmLgLW9KgTg1BpsxX": [
{
"new_file_name": "5bfb97e92dbde.jpg",
"original_file_name": "128483.1.jpg"
},
{
"new_file_name": "5bfb97e92dd09.jpg",
"original_file_name": "amit.jpg"
},
....
]

}
},
"users_slug": {
"-LSDmLgLW9KgTg1BpsxX": [
{
"new_file_name": "5bfb97e92dbde.jpg",
"original_file_name": "128483.1.jpg",
"user_id": "-LSDmLO1GyfbumPZPopb"
},
..........
]
}
}


Finally, you may watch this official Firebase video series about "The Firebase Database For SQL Developers" https://www.youtube.com/playlist?list=PLl-K7zZEsYLlP-k-RKFa7RyNPa9_wCH2s and in particular the 6th video on denormalization https://www.youtube.com/watch?v=vKqXSZLLnHA&index=7&list=PLl-K7zZEsYLlP-k-RKFa7RyNPa9_wCH2s&t=0s






share|improve this answer















(If I understand correctly your needs) you could denormalize your data like the following, by duplicating the slug data of each user under each user node.



This way you only need one query to get all the "slugs" of a given user.



You may keep the users_slug node (i.e. "collection" to use the vocabulary of your post) if you need to make some specific queries. (For example queries to the -LSDmLgLW9KgTg1BpsxX node -or to future siblings-, but it is not clear what is this uniqueId).



Denormalizing is quite common in NoSQL world and you should not hesitate to duplicate your data, in order to optimize your queries. Note that to simultaneously write to two (or more) nodes, in order to manage data consistency, you can use the update() method, see the docs here and here.



{
"users": {
"-LSDmLO1GyfbumPZPopb": {
"first_name": "test",
"gender": "M",
"last_name": "test123",
"username": "test123"
"slugs": {
"-LSDmLgLW9KgTg1BpsxX": [
{
"new_file_name": "5bfb97e92dbde.jpg",
"original_file_name": "128483.1.jpg"
},
{
"new_file_name": "5bfb97e92dd09.jpg",
"original_file_name": "amit.jpg"
},
....
]

}
},
"users_slug": {
"-LSDmLgLW9KgTg1BpsxX": [
{
"new_file_name": "5bfb97e92dbde.jpg",
"original_file_name": "128483.1.jpg",
"user_id": "-LSDmLO1GyfbumPZPopb"
},
..........
]
}
}


Finally, you may watch this official Firebase video series about "The Firebase Database For SQL Developers" https://www.youtube.com/playlist?list=PLl-K7zZEsYLlP-k-RKFa7RyNPa9_wCH2s and in particular the 6th video on denormalization https://www.youtube.com/watch?v=vKqXSZLLnHA&index=7&list=PLl-K7zZEsYLlP-k-RKFa7RyNPa9_wCH2s&t=0s







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 26 '18 at 11:44

























answered Nov 26 '18 at 11:32









Renaud TarnecRenaud Tarnec

12.7k21734




12.7k21734













  • how to I fetch data from this collection by '-LSEufUsgTiWMESbAZfO' ID? Array ( [-LSEufnnC_fTx1svGGv8] => Array ( [slug_node_key] => -LSEufdEJ_d4ZhnqbUJA [user_node_key] => -LSEufUsgTiWMESbAZfO ) )

    – Vivek Singh
    Nov 26 '18 at 12:17











  • I am not sure to understand what you mean. You may be more precise on which exact queries you want to execute, independently of the initial data model. E.g. all users with a certain slug? all slugs for a user? etc.

    – Renaud Tarnec
    Nov 26 '18 at 15:58













  • i just want to filter data from 2 collection based on node key which is primary key in one collection and reference key in another collection

    – Vivek Singh
    Nov 28 '18 at 4:26



















  • how to I fetch data from this collection by '-LSEufUsgTiWMESbAZfO' ID? Array ( [-LSEufnnC_fTx1svGGv8] => Array ( [slug_node_key] => -LSEufdEJ_d4ZhnqbUJA [user_node_key] => -LSEufUsgTiWMESbAZfO ) )

    – Vivek Singh
    Nov 26 '18 at 12:17











  • I am not sure to understand what you mean. You may be more precise on which exact queries you want to execute, independently of the initial data model. E.g. all users with a certain slug? all slugs for a user? etc.

    – Renaud Tarnec
    Nov 26 '18 at 15:58













  • i just want to filter data from 2 collection based on node key which is primary key in one collection and reference key in another collection

    – Vivek Singh
    Nov 28 '18 at 4:26

















how to I fetch data from this collection by '-LSEufUsgTiWMESbAZfO' ID? Array ( [-LSEufnnC_fTx1svGGv8] => Array ( [slug_node_key] => -LSEufdEJ_d4ZhnqbUJA [user_node_key] => -LSEufUsgTiWMESbAZfO ) )

– Vivek Singh
Nov 26 '18 at 12:17





how to I fetch data from this collection by '-LSEufUsgTiWMESbAZfO' ID? Array ( [-LSEufnnC_fTx1svGGv8] => Array ( [slug_node_key] => -LSEufdEJ_d4ZhnqbUJA [user_node_key] => -LSEufUsgTiWMESbAZfO ) )

– Vivek Singh
Nov 26 '18 at 12:17













I am not sure to understand what you mean. You may be more precise on which exact queries you want to execute, independently of the initial data model. E.g. all users with a certain slug? all slugs for a user? etc.

– Renaud Tarnec
Nov 26 '18 at 15:58







I am not sure to understand what you mean. You may be more precise on which exact queries you want to execute, independently of the initial data model. E.g. all users with a certain slug? all slugs for a user? etc.

– Renaud Tarnec
Nov 26 '18 at 15:58















i just want to filter data from 2 collection based on node key which is primary key in one collection and reference key in another collection

– Vivek Singh
Nov 28 '18 at 4:26





i just want to filter data from 2 collection based on node key which is primary key in one collection and reference key in another collection

– Vivek Singh
Nov 28 '18 at 4:26




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53477301%2ffetching-data-from-2-collections-in-firebase%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Create new schema in PostgreSQL using DBeaver

Deepest pit of an array with Javascript: test on Codility

Costa Masnaga