How do I structure a firebase database for this case?
up vote
0
down vote
favorite
Basically I would like to display every tobacco and all the available hookahs in a UITableView, based on if the tobacco segment or the hookah segment is pressed. First you should see the brand and after that the "products" (like all tobaccos or hookahs).
So now, how exactly should the firebase database then look like? Because every product (hookah, tobacco) should have a "name", "brand", "rating" and "description".
The second question: How would I receive all these informations in my tableview by code? For now I am working with the following structure of sections for my tableview which is dependent on the var p if it is 0 or 1. Then it selects the section on index 0 or 1 (based on which segment is clicked).
var sections = [[Section(brand: "7 Days", products: ["Tabak1", "Tabak2", "Tabak3"], expanded: false),
Section(brand: "Zomo", products: ["Tabak1", "Tabak2", "Tabak3"], expanded: false)],
[Section(brand: "Aeon", products: ["Shisha1", "Shisha2", "Shisha3"], expanded: false),
Section(brand: "Vendetta", products: ["Shisha1", "Shisha2", "Shisha3"], expanded: false)]]
What the tableView looks like when its expanded
I would really appreciate any answer to any of the two problems.
Thank you!
swift firebase
add a comment |
up vote
0
down vote
favorite
Basically I would like to display every tobacco and all the available hookahs in a UITableView, based on if the tobacco segment or the hookah segment is pressed. First you should see the brand and after that the "products" (like all tobaccos or hookahs).
So now, how exactly should the firebase database then look like? Because every product (hookah, tobacco) should have a "name", "brand", "rating" and "description".
The second question: How would I receive all these informations in my tableview by code? For now I am working with the following structure of sections for my tableview which is dependent on the var p if it is 0 or 1. Then it selects the section on index 0 or 1 (based on which segment is clicked).
var sections = [[Section(brand: "7 Days", products: ["Tabak1", "Tabak2", "Tabak3"], expanded: false),
Section(brand: "Zomo", products: ["Tabak1", "Tabak2", "Tabak3"], expanded: false)],
[Section(brand: "Aeon", products: ["Shisha1", "Shisha2", "Shisha3"], expanded: false),
Section(brand: "Vendetta", products: ["Shisha1", "Shisha2", "Shisha3"], expanded: false)]]
What the tableView looks like when its expanded
I would really appreciate any answer to any of the two problems.
Thank you!
swift firebase
This isn't a code writing service but we will be happy to help you with existing code you're having difficulty with. If you are asking how to Read Data from Firebase, it's pretty well covered in the documentation. To do your structure 'right' we would need more information. i.e. are you going to query your child nodes? If so, what for? How your data is structured is directly related to what you want to get out of it. Write some code and update your question when you get stuck.
– Jay
Nov 25 at 13:27
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Basically I would like to display every tobacco and all the available hookahs in a UITableView, based on if the tobacco segment or the hookah segment is pressed. First you should see the brand and after that the "products" (like all tobaccos or hookahs).
So now, how exactly should the firebase database then look like? Because every product (hookah, tobacco) should have a "name", "brand", "rating" and "description".
The second question: How would I receive all these informations in my tableview by code? For now I am working with the following structure of sections for my tableview which is dependent on the var p if it is 0 or 1. Then it selects the section on index 0 or 1 (based on which segment is clicked).
var sections = [[Section(brand: "7 Days", products: ["Tabak1", "Tabak2", "Tabak3"], expanded: false),
Section(brand: "Zomo", products: ["Tabak1", "Tabak2", "Tabak3"], expanded: false)],
[Section(brand: "Aeon", products: ["Shisha1", "Shisha2", "Shisha3"], expanded: false),
Section(brand: "Vendetta", products: ["Shisha1", "Shisha2", "Shisha3"], expanded: false)]]
What the tableView looks like when its expanded
I would really appreciate any answer to any of the two problems.
Thank you!
swift firebase
Basically I would like to display every tobacco and all the available hookahs in a UITableView, based on if the tobacco segment or the hookah segment is pressed. First you should see the brand and after that the "products" (like all tobaccos or hookahs).
So now, how exactly should the firebase database then look like? Because every product (hookah, tobacco) should have a "name", "brand", "rating" and "description".
The second question: How would I receive all these informations in my tableview by code? For now I am working with the following structure of sections for my tableview which is dependent on the var p if it is 0 or 1. Then it selects the section on index 0 or 1 (based on which segment is clicked).
var sections = [[Section(brand: "7 Days", products: ["Tabak1", "Tabak2", "Tabak3"], expanded: false),
Section(brand: "Zomo", products: ["Tabak1", "Tabak2", "Tabak3"], expanded: false)],
[Section(brand: "Aeon", products: ["Shisha1", "Shisha2", "Shisha3"], expanded: false),
Section(brand: "Vendetta", products: ["Shisha1", "Shisha2", "Shisha3"], expanded: false)]]
What the tableView looks like when its expanded
I would really appreciate any answer to any of the two problems.
Thank you!
swift firebase
swift firebase
edited Nov 22 at 17:18
rmaddy
237k27308374
237k27308374
asked Nov 22 at 16:26
F. Leeser
34
34
This isn't a code writing service but we will be happy to help you with existing code you're having difficulty with. If you are asking how to Read Data from Firebase, it's pretty well covered in the documentation. To do your structure 'right' we would need more information. i.e. are you going to query your child nodes? If so, what for? How your data is structured is directly related to what you want to get out of it. Write some code and update your question when you get stuck.
– Jay
Nov 25 at 13:27
add a comment |
This isn't a code writing service but we will be happy to help you with existing code you're having difficulty with. If you are asking how to Read Data from Firebase, it's pretty well covered in the documentation. To do your structure 'right' we would need more information. i.e. are you going to query your child nodes? If so, what for? How your data is structured is directly related to what you want to get out of it. Write some code and update your question when you get stuck.
– Jay
Nov 25 at 13:27
This isn't a code writing service but we will be happy to help you with existing code you're having difficulty with. If you are asking how to Read Data from Firebase, it's pretty well covered in the documentation. To do your structure 'right' we would need more information. i.e. are you going to query your child nodes? If so, what for? How your data is structured is directly related to what you want to get out of it. Write some code and update your question when you get stuck.
– Jay
Nov 25 at 13:27
This isn't a code writing service but we will be happy to help you with existing code you're having difficulty with. If you are asking how to Read Data from Firebase, it's pretty well covered in the documentation. To do your structure 'right' we would need more information. i.e. are you going to query your child nodes? If so, what for? How your data is structured is directly related to what you want to get out of it. Write some code and update your question when you get stuck.
– Jay
Nov 25 at 13:27
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
If you are simply reading data and will never query for anything it's pretty straightforward
root
all_data
data_0 //created with .childByAutoId
brand: "7 days"
products:
"Tabak1": true
"Tabak2": true
data_1
brand: "Zomo"
products:
"Tabak1": true
"Tabak2": true
data_3
brand: "Aeon"
products:
"Shisha1": true
"Shisha2": true
however, this will lead to issues* if for example you want to query for all brands that have Tabak2 products. So here's an alternative that would enable you to easily determine the brand nodes that have Tabak2
root
brands
brand_0
brand: "7 days"
brand_1
brand: "Zomo"
brand_2
brand: "Aeon"
products_by_brand
brand_0
"Tabak1": true
"Tabak2": true
brand_1
"Tabak1": true
"Tabak2": true
brand_2
"Shisha1": true
"Shisha2": true
And if you want to be super cool then here's a structure that cross references all products and brands which would allow for a variety of queries and allow you to link single products back to multiple brands and vice-versa
root
brands
brand_0 //created with .childByAutoId
brand: "7 days"
product_0: true //products should probably be in a child node
product_1: true
brand_1
brand: "Zomo"
product_0: true
product_1: true
all_products
product_0
name: "Tabak1"
brand_0: true
brand_1: true
product_1
name: "Tabak2"
brand_0: true
brand_1: true
*this can actually be accomplished via a deep path query
add a comment |
up vote
-1
down vote
brands -> products -> tobacco -> uniqueId -> name, rating and description
-> hookah -> uniqueId -> name, rating and description
I'm not sure if you need to include the brand in the product details since that would be the main parent.
Hope this helps :)
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
If you are simply reading data and will never query for anything it's pretty straightforward
root
all_data
data_0 //created with .childByAutoId
brand: "7 days"
products:
"Tabak1": true
"Tabak2": true
data_1
brand: "Zomo"
products:
"Tabak1": true
"Tabak2": true
data_3
brand: "Aeon"
products:
"Shisha1": true
"Shisha2": true
however, this will lead to issues* if for example you want to query for all brands that have Tabak2 products. So here's an alternative that would enable you to easily determine the brand nodes that have Tabak2
root
brands
brand_0
brand: "7 days"
brand_1
brand: "Zomo"
brand_2
brand: "Aeon"
products_by_brand
brand_0
"Tabak1": true
"Tabak2": true
brand_1
"Tabak1": true
"Tabak2": true
brand_2
"Shisha1": true
"Shisha2": true
And if you want to be super cool then here's a structure that cross references all products and brands which would allow for a variety of queries and allow you to link single products back to multiple brands and vice-versa
root
brands
brand_0 //created with .childByAutoId
brand: "7 days"
product_0: true //products should probably be in a child node
product_1: true
brand_1
brand: "Zomo"
product_0: true
product_1: true
all_products
product_0
name: "Tabak1"
brand_0: true
brand_1: true
product_1
name: "Tabak2"
brand_0: true
brand_1: true
*this can actually be accomplished via a deep path query
add a comment |
up vote
0
down vote
accepted
If you are simply reading data and will never query for anything it's pretty straightforward
root
all_data
data_0 //created with .childByAutoId
brand: "7 days"
products:
"Tabak1": true
"Tabak2": true
data_1
brand: "Zomo"
products:
"Tabak1": true
"Tabak2": true
data_3
brand: "Aeon"
products:
"Shisha1": true
"Shisha2": true
however, this will lead to issues* if for example you want to query for all brands that have Tabak2 products. So here's an alternative that would enable you to easily determine the brand nodes that have Tabak2
root
brands
brand_0
brand: "7 days"
brand_1
brand: "Zomo"
brand_2
brand: "Aeon"
products_by_brand
brand_0
"Tabak1": true
"Tabak2": true
brand_1
"Tabak1": true
"Tabak2": true
brand_2
"Shisha1": true
"Shisha2": true
And if you want to be super cool then here's a structure that cross references all products and brands which would allow for a variety of queries and allow you to link single products back to multiple brands and vice-versa
root
brands
brand_0 //created with .childByAutoId
brand: "7 days"
product_0: true //products should probably be in a child node
product_1: true
brand_1
brand: "Zomo"
product_0: true
product_1: true
all_products
product_0
name: "Tabak1"
brand_0: true
brand_1: true
product_1
name: "Tabak2"
brand_0: true
brand_1: true
*this can actually be accomplished via a deep path query
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
If you are simply reading data and will never query for anything it's pretty straightforward
root
all_data
data_0 //created with .childByAutoId
brand: "7 days"
products:
"Tabak1": true
"Tabak2": true
data_1
brand: "Zomo"
products:
"Tabak1": true
"Tabak2": true
data_3
brand: "Aeon"
products:
"Shisha1": true
"Shisha2": true
however, this will lead to issues* if for example you want to query for all brands that have Tabak2 products. So here's an alternative that would enable you to easily determine the brand nodes that have Tabak2
root
brands
brand_0
brand: "7 days"
brand_1
brand: "Zomo"
brand_2
brand: "Aeon"
products_by_brand
brand_0
"Tabak1": true
"Tabak2": true
brand_1
"Tabak1": true
"Tabak2": true
brand_2
"Shisha1": true
"Shisha2": true
And if you want to be super cool then here's a structure that cross references all products and brands which would allow for a variety of queries and allow you to link single products back to multiple brands and vice-versa
root
brands
brand_0 //created with .childByAutoId
brand: "7 days"
product_0: true //products should probably be in a child node
product_1: true
brand_1
brand: "Zomo"
product_0: true
product_1: true
all_products
product_0
name: "Tabak1"
brand_0: true
brand_1: true
product_1
name: "Tabak2"
brand_0: true
brand_1: true
*this can actually be accomplished via a deep path query
If you are simply reading data and will never query for anything it's pretty straightforward
root
all_data
data_0 //created with .childByAutoId
brand: "7 days"
products:
"Tabak1": true
"Tabak2": true
data_1
brand: "Zomo"
products:
"Tabak1": true
"Tabak2": true
data_3
brand: "Aeon"
products:
"Shisha1": true
"Shisha2": true
however, this will lead to issues* if for example you want to query for all brands that have Tabak2 products. So here's an alternative that would enable you to easily determine the brand nodes that have Tabak2
root
brands
brand_0
brand: "7 days"
brand_1
brand: "Zomo"
brand_2
brand: "Aeon"
products_by_brand
brand_0
"Tabak1": true
"Tabak2": true
brand_1
"Tabak1": true
"Tabak2": true
brand_2
"Shisha1": true
"Shisha2": true
And if you want to be super cool then here's a structure that cross references all products and brands which would allow for a variety of queries and allow you to link single products back to multiple brands and vice-versa
root
brands
brand_0 //created with .childByAutoId
brand: "7 days"
product_0: true //products should probably be in a child node
product_1: true
brand_1
brand: "Zomo"
product_0: true
product_1: true
all_products
product_0
name: "Tabak1"
brand_0: true
brand_1: true
product_1
name: "Tabak2"
brand_0: true
brand_1: true
*this can actually be accomplished via a deep path query
answered Nov 25 at 13:40
Jay
18.3k42848
18.3k42848
add a comment |
add a comment |
up vote
-1
down vote
brands -> products -> tobacco -> uniqueId -> name, rating and description
-> hookah -> uniqueId -> name, rating and description
I'm not sure if you need to include the brand in the product details since that would be the main parent.
Hope this helps :)
add a comment |
up vote
-1
down vote
brands -> products -> tobacco -> uniqueId -> name, rating and description
-> hookah -> uniqueId -> name, rating and description
I'm not sure if you need to include the brand in the product details since that would be the main parent.
Hope this helps :)
add a comment |
up vote
-1
down vote
up vote
-1
down vote
brands -> products -> tobacco -> uniqueId -> name, rating and description
-> hookah -> uniqueId -> name, rating and description
I'm not sure if you need to include the brand in the product details since that would be the main parent.
Hope this helps :)
brands -> products -> tobacco -> uniqueId -> name, rating and description
-> hookah -> uniqueId -> name, rating and description
I'm not sure if you need to include the brand in the product details since that would be the main parent.
Hope this helps :)
answered Nov 22 at 16:53
Zeel Mehta
193
193
add a comment |
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435005%2fhow-do-i-structure-a-firebase-database-for-this-case%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
This isn't a code writing service but we will be happy to help you with existing code you're having difficulty with. If you are asking how to Read Data from Firebase, it's pretty well covered in the documentation. To do your structure 'right' we would need more information. i.e. are you going to query your child nodes? If so, what for? How your data is structured is directly related to what you want to get out of it. Write some code and update your question when you get stuck.
– Jay
Nov 25 at 13:27