I'm working on creating a checkbook app for android using a database to record transactions. The design I'd envisioned was/is to allow the user the ability to create different "accounts" (savings account, checking account, etc) under whatever name they choose and use that as the database table name. However, using preparedStatements doesn't work when I try to create a table. So I'm wondering if I'm going to need to sanitize the input manually or if I'm missing something. This is my first Java/android database program and I've got no formal education in databases so its possible I completely missed something. **edited to reflect more accurately what I meant by account. As this will be on an android device I have no interest in multiuser setup.
1
-
Unless you are storing heterogeneous data, I do not see the point on why you would create a new table for each user. Although if you still want to create new table, you could do that by using sqllitehelper. It has a overriden method for createtable. Use this instead of prepared statements.billygoat– billygoat2011-04-11 22:13:24 +00:00Commented Apr 11, 2011 at 22:13
Add a comment
|
1 Answer
Probably, you don't need a table for each user. You should revise your database structure.
4 Comments
jwp
Sorry I was more clear, but its not based on users but accounts as in savings account or checking account.
Marcos Vasconcelos
Also, you still don't need a table named specially for device. You can has an general "account" table which contains the data from the user.
jwp
So, create a table named "account" then provide a column that would seperate deposits and withdrawls from different accounts? For example, to show only deposits and withdrawls from the savings account, SELECT * FROM accounts WHERE accountType = "savings".
jwp
Cool. I plan on providing a list of the accounts so I'm thinking of using a table for just the account names then providing a foreign key reference in the accounts table. Any problems that you foresee?