SQL
CREATE TABLE users_to_recipes (
user_id CHAR(32) NOT NULL,
recipe_id CHAR(32) NOT NULL,
rating FLOAT,
is_favorite BOOLEAN NOT NULL,
id CHAR(32) NOT NULL,
created_at DATETIME,
update_at DATETIME,
PRIMARY KEY (user_id, recipe_id, id),
FOREIGN KEY(recipe_id) REFERENCES recipes (id),
FOREIGN KEY(user_id) REFERENCES users (id),
CONSTRAINT user_id_recipe_id_rating_key UNIQUE (user_id, recipe_id)
)
Columns
| Column | Data type | Allow null | Primary key | Actions |
|---|---|---|---|---|
user_id |
CHAR(32) |
✓ | Rename | Drop | |
recipe_id |
CHAR(32) |
✓ | Rename | Drop | |
rating |
FLOAT |
✓ | Rename | Drop | |
is_favorite |
BOOLEAN |
Rename | Drop | ||
id |
CHAR(32) |
✓ | Rename | Drop | |
created_at |
DATETIME |
✓ | Rename | Drop | |
update_at |
DATETIME |
✓ | Rename | Drop |
Foreign Keys
| Column | Destination |
|---|---|
user_id |
users.id |
recipe_id |
recipes.id |
Indexes
| Name | Columns | Unique | SQL | Drop? |
|---|---|---|---|---|
| ix_users_to_recipes_created_at |
created_at
|
SQL | Drop | |
| ix_users_to_recipes_is_favorite |
is_favorite
|
SQL | Drop | |
| ix_users_to_recipes_rating |
rating
|
SQL | Drop | |
| ix_users_to_recipes_recipe_id |
recipe_id
|
SQL | Drop | |
| ix_users_to_recipes_user_id |
user_id
|
SQL | Drop | |
| sqlite_autoindex_users_to_recipes_1 |
|
✓ | SQL | Drop |
| sqlite_autoindex_users_to_recipes_2 |
|
✓ | SQL | Drop |