vendredi 23 janvier 2015

SQLite Android: searching function for multiple tables?

I am really new to database, so please bare with me and PLEASE try to help me!! :)


I am making an app which is pretty much like this:



  1. Register a customer;

  2. Add different types of math calculations to this customer;

  3. Now this customer has a list full of specific calculations.


Everything is working pretty good so far. But the thing is, how could I make a sqlite function in my db class that would list ONLY the calcs of a specific customer? e.g. when I select one specific customer, I don't want to see the calcs of other customers, only of this specific one.


I have 2 tables:



Customer (_id, name, email)
Calculations (_id, customer_id, date, value1, value2, result)


is there anyway I could like add a new column to Customer which would be like "calcs_made" and then it would call ALL "Calculations" table's columns?


I thought of searching the "customer_id" that the user is looking for and showing only the lines with that matching information, but it doesn't sound like a good practice.


The "Calculations" table is the first and only one so far, but there will be many others with different types of calcs as I update the app, therefore it would have to be really flexible.


I have no idea what to do, please help me guys!


Thanks in advance! :)


Aucun commentaire:

Enregistrer un commentaire