1
I’m creating an app to monitor aquarium settings using the following schema:
The user can monitor as many aquariums as he wants, but every time he adds a new tank, these two tables should be created and always linked.
And the water parameters need to be maintained over time, because I’m going to use them in a graph. Showing the changes over time. For example, a chart showing the amount of salt over a week.
That’s where my doubt comes in, because I’m just starting to program.
- How can I create and join these two tables every time the user adds a new aquarium?
- And how I would do not mix with other tables, if the user had added 5 aquariums in the app?
I’ve been doing some research and seen what foreign key might be useful in my case, but I don’t know if it would help me, or how to proceed.
Note: Just a clarification. I do not need the be-a-bá, I have a basic knowledge on Android. I know how to handle a db, do CRUD operations, Cursor, Contentprovider, etc. But I am lost in this case. I would not like to pass the impression of laziness. Just no sense of which way to go, or what tools to use.
Why two different tables? Can an aquarium have more than one parameter and/or vice versa? I believe not, and the best solution would be to unite both tables. If you want to research more about cardinality in the relations between tables
– Costamilam
I’m not sure I understand your question, but I’ll try to clarify. Two tables why the information from the Quario itself does not change, but the parameters do. For example, the salinity of the water changes over time, the pH of the water can change very quickly over the course of the hours, or days. The user may very well want to record the parameters several times lasting the day, or the week. So I got the idea of having a table exclusively for the paramenters. But if you can still do it in one table, what would it be like? I want to keep data over time to display a chart
– Nakamoto
So the relation between aquarium and parameters and 1:N, because you always want to keep track of previous parameters, it would not be interesting to add a date field?
– Costamilam
I want to keep the record of the data to display a graph. I think I do this using date and time. I think I have now managed to explain it better.
– Nakamoto