Skip to content

Instantly share code, notes, and snippets.

@hi-im-aj
Last active February 8, 2021 13:50
Show Gist options
  • Save hi-im-aj/8261c9f145eff9aafcccbf1ec58ba425 to your computer and use it in GitHub Desktop.
Save hi-im-aj/8261c9f145eff9aafcccbf1ec58ba425 to your computer and use it in GitHub Desktop.
CREATE TABLE recipeIngredientRelations(
id INTEGER
constraint table_name_pk
primary key autoincrement,
recipeId INTEGER,
ingredientId INTEGER,
unit INTEGER,
amount REAL
);
CREATE TABLE recipes(
id INTEGER
constraint table_name_pk
primary key autoincrement,
name TEXT NOT NULL,
image TEXT,
description TEXT
);
CREATE TABLE ingredients(
id INTEGER
constraint table_name_pk
primary key autoincrement,
name TEXT,
kcalPer100g REAL
);
CREATE TABLE units(
id INTEGER
constraint table_name_pk
primary key autoincrement,
name TEXT
);
INSERT INTO recipes (name, image, description) VALUES ('Weird Mix', 'WeirdMix.png', 'Hello World!'), ('qwe', 'qwe.png', 'Hello World!2'), ('ZXC', 'ZXC.png', 'Hello World!3');
INSERT INTO ingredients (name, kcalPer100g) VALUES ('Broccoli', 34), ('Egg', 108), ('Pointed cabbage', 28), ('Banana', 204), ('Apple', 34);
SELECT * FROM ingredients ORDER BY name;
update recipes set name = 'qweQwe' WHERE id = 2;
DELETE FROM recipes WHERE id = 2;
SELECT * FROM recipes ORDER BY name;
SELECT * FROM ingredients ORDER BY name DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment