-2

I'm trying to build a chore app where the user can create a group with a password and they can then add chores to the group that they made. My question is I'm using sqlite as the database and I'm wondering if it's possible to add a database column into the table. I'm planning on creating a table inside my db with columns of id, username, password, database. database is where I will create additional databases where it will store the chore table for my app. If I can't do this, can someone lead me along the way on how I can for example, make a table named Group, then for its columns have id, username, password. Then for each Group rows, be able to somehow match it with another corresponding database or table where the table will be chores with columns say name, frequency. And however many Group rows I add, I will need to somehow make another chore table to match with it, but I need to know how to link and refer to it from just my Group table. If there's a better way to do this using SQLite I would love to know. Thank you.

Minh Vu
  • 11
  • 2
  • `GROUP` is a reserved keyword. But you can make a table named `Groups` (which also makes more sense, since it will contain more than a single group - and it's also a **normalized** table name), instead. – Phantômaxx Oct 30 '15 at 08:22

1 Answers1

0

If i get your question correctly, I think all u need is to use PRIMARY_KEY and FOREIGN_KEY. Hope you are aware of constraints in databases.

So basically two tables will share a KEY which is unique, the key will be the PRIMARY_KEY in table 1 and will act as a link or reference to row in second table, where it is a FOREIGN_KEY

check this for more on constraints

Community
  • 1
  • 1
Seeker
  • 1,030
  • 10
  • 10
  • So I don't need to make multiple Chore tables? Only one and have a FOREIGN_KEY to know which groups it belongs to? – Minh Vu Oct 30 '15 at 10:21
  • Exactly. A table for Chores which will map to it's group with FOREIGN_KEY. And you certainly don't need to have multiple database instances. One db with multiple tables will do. – Seeker Oct 30 '15 at 11:20