New answers tagged

3 votes
Accepted

What foreign key should I store from users table or clients table?

... only a client can buy a course ... Bingo! There you have a Business Rule that states that the relationship is between [Purchased_]Course and Client, not [Purchased_]Course and User. So you would ...
Phill  W.'s user avatar
  • 8,558
2 votes
Accepted

How do you only get data from the table with the foreign key using SQLite?

The secret is in double quotes: https://www.sqlite.org/lang_keywords.html A string in double-quotes is an identifier. It is used primarily for cases where you have field name with a space inside or ...
White Owl's user avatar
  • 757
2 votes

How do I write sensible FOREIGN KEY CONSTRAINTS if the PRIMARY KEYS from two tables can reference multiple of the other table's PK

I am reluctant to give the "users" table several "workgroup" columns (like "workgroup1", "workgroup2", etc) and equally reluctant to give the "workgroups&...
Phill  W.'s user avatar
  • 8,558
2 votes

How can I know how many tables my DELETE has changed?

... I could delete one row from one table in a sufficiently evil database and unknowingly delete 99% of the database's data. Absolutely correct. One of the biggest threats to our databases is the &...
Phill  W.'s user avatar
  • 8,558
2 votes

How can I know how many tables my DELETE has changed?

You could get this information out of the Actual query plan. If you want to parse the query plan to find out how many rows were actually affected, you can do it like this. WITH XMLNAMESPACES ( ...
Charlieface's user avatar
  • 12.5k

Top 50 recent answers are included