CharityBunyon / activateMe

0 stars 0 forks source link

Create Database #3

Closed CharityBunyon closed 4 years ago

CharityBunyon commented 4 years ago

Developer Story

As a developer, I am going to create a database that will show the relationships between multiple tables.

AC

WHEN THEN AND

Dev Notes

CharityBunyon commented 4 years ago

create table [User]( ID int primary key identity (1,1) not null, firstname varchar(255) not null, lastname varchar(255) not null, dateJoined DateTime not null, userName varchar(255)null, Email varchar(255) null, city varchar(255) null, [state] varchar(255) null, imageUrl varchar(255) null, points int null, badgeId varchar(255) null )

create table Badges ( badgeId int primary key identity (1,1) not null, [name] varchar(255) null, pointValue int null, imageUrl varchar(255) null )

create table SampleExercises ( id int primary key identity (1,1) not null, [name] varchar(255) not null, imageUrl varchar(255) null, link varchar(255) null )

create table SampleRecipes ( id int primary key identity (1,1) not null, [name] varchar(255) not null, imageUrl varchar(255) not null, link varchar(255) not null )

create table Food ( id int primary key identity (1,1) not null, [name] varchar(255) not null, foodType varchar(255) not null, quantity int null, calories int null, points int null )

create table FoodCategory ( id int primary key identity (1,1) not null, [type] varchar(255) not null, )

create table Exercise ( id int primary key identity (1,1) not null, [name] varchar(255) not null, categoryType varchar(255) not null, [time] int null, calories int null, points int null )

create table ExerciseCategory ( id int primary key identity (1,1) not null, [type] varchar(255) not null, )

create table Dashboard ( id int primary key identity (1,1) not null, userPoints int null, badgeId int null, sampleExerciseId int null, sampleRecipesId int null, )

create table [Log] ( id int primary key identity (1,1) not null, exerciseId int not null, foodId int not null, caloriesFromFood int null, )

CharityBunyon commented 4 years ago

Table Data

insert into [User] (firstname, lastname, dateJoined, username, Email, city, state, imageUrl, points) values('James', 'Baldwin', getdate(), 'jbadwin', 'jBadwin@test.com', 'Harlem', 'NYC','https://www.biography.com/.image/t_share/MTE4MDAzNDEwNDQ0NzE1NTM0/james-baldwin-9196635-2-402.jpg' ,0,), ('Maya', 'Angelou', getdate(), 'mAngelou', 'mAngelou@test.com','St.Louis', 'MO', 'https://static01.nyt.com/images/2014/05/29/obituaries/ANGELOU/ANGELOU-superJumbo.jpg', 0), ('Jean-Michel', 'Basquiat', getdate(), 'jBasquiat', 'jBasquiat@test.com', 'Brooklyn', 'NYC', 'https://uploads3.wikiart.org/images/jean-michel-basquiat.jpg!Portrait.jpg', 0)

insert into Badge(name, pointValue, imageUrl) values('Feel The Burn',50 , 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/Badge%20Images/burn.png'), ('Eat Well', 100, 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/Badge%20Images/eat-well.png'), ('Fiber', 150, 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/Badge%20Images/fiber.png'), ('Flexin', 200, 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/Badge%20Images/flexin.png'), ('Get It', 300, 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/Badge%20Images/get-it.png'), ('Heart', 400, 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/Badge%20Images/heart.png'), ('Plant Power', 500, 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/Badge%20Images/plant-power.png'), ('Running', 600, 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/Badge%20Images/running.png'), ('Sweating', 700, 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/Badge%20Images/sweat.png'), ('Water', 800, 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/Badge%20Images/water.png')

insert into SampleRecipes(name, imageUrl, link) values('Roasted Balsamic Red Potatoes', 'https://github.com/CharityBunyon/activateMe/blob/master/activateme.ui/src/assets/recipe%20Images/red-potato.jpg', 'https://www.tasteofhome.com/recipes/roasted-balsamic-red-potatoes/'), ('General Tso's Cauliflower', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/recipe%20Images/General-Tso-s-Cauliflower.jpg', 'https://www.tasteofhome.com/recipes/general-tso-s-cauliflower/'), ('Spicy Grilled Broccoli', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/recipe%20Images/grilled-broccoli.jpg', 'https://www.tasteofhome.com/recipes/spicy-grilled-broccoli/'), ('Green Beans un Red Pepper Sauce', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/recipe%20Images/green-beans.jpg', 'https://www.tasteofhome.com/recipes/green-beans-in-red-pepper-sauce/'), ('Black Bean & Corn Quinoa', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/recipe%20Images/bean-quinoa.jpg', 'https://www.tasteofhome.com/recipes/green-beans-in-red-pepper-sauce/'), ('Easy Hummus', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/recipe%20Images/hummus.jpg', 'https://www.inspiredtaste.net/15938/easy-and-smooth-hummus-recipe/'), ('Best Black Bean Burger', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/recipe%20Images/best-black-bean-burgers.jpg', 'https://sallysbakingaddiction.com/best-black-bean-burgers/'), ('Grilled Red Cabbage with Lime Sour Cream Dressing', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/recipe%20Images/purple-cabbage.jpg', 'https://magnoliadays.com/grilled-red-cabbage-lime-sour-cream-dressing/'), ('Orecchiette Pasta with Broccoli Sauce', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/recipe%20Images/pasta-broccoli.jpg', 'https://www.feastingathome.com/orecchiette-pasta-with-broccoli-sauce/'), ('Eggplant Parmesan', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/recipe%20Images/eggplant.jpg', 'https://thestayathomechef.com/baked-eggplant-parmesan/'), ('Kyoto Style Sweet Potatoes with Miso, Ginger and Scallions', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/recipe%20Images/Miso-Sweet-Potatoes-108.jpg', 'https://www.feastingathome.com/roasted-sweet-potatoes-with-miso/'), ('Vegetarian Kimchi Burritos', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/recipe%20Images/Kimchi-Burrito-8.jpg', 'https://www.feastingathome.com/kimchi-burrito/'), ('Indian Coconut Lentil Curry', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/recipe%20Images/Instant-Pot-coconut-curry-lentils-101.jpg', 'https://www.feastingathome.com/coconut-lentil-curry/'), ('Roasted Butternut Soup','https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/recipe%20Images/butternut-soup-104.jpg', 'feastingathome.com/roasted-butternut-apple-soup/'), ('Tomato Soup with Halloumi Croutons', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/recipe%20Images/Roasted-Tomato-Soup-100-2.jpg', 'https://www.feastingathome.com/roasted-tomato-soup-haloumi-croutons-yogurt-sumac/'), ('Enchilada Stuffed Spaghetti Squash', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/recipe%20Images/enchilada-2Bstuffed-2Bspaghetti-2Bsquash-117.jpg', 'https://www.feastingathome.com/enchilada-stuffed-spaghetti-squash/')

insert into SampleExercises(name, imageUrl, link) values('Supermans','https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/exercise%20Images/supermans.jpg', ' https://www.acefitness.org/education-and-resources/lifestyle/exercise-library/9/supermans/'), ('Push-Up', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/exercise%20Images/push-up.jpg', 'https://www.acefitness.org/education-and-resources/lifestyle/exercise-library/41/push-up/'), ('Contralateral Limb Raises', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/exercise%20Images/limb-raises.jpg', 'https://www.acefitness.org/education-and-resources/lifestyle/exercise-library/53/contralateral-limb-raises/'), ('Bent Knee Push-Up', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/exercise%20Images/bent-knee.jpg', 'https://www.acefitness.org/education-and-resources/lifestyle/exercise-library/13/bent-knee-push-up/'), ('Downward-facing Dog','https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/exercise%20Images/downward-facing.jpg', 'https://www.acefitness.org/education-and-resources/lifestyle/exercise-library/13/bent-knee-push-up/'), ('Crunch', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/exercise%20Images/crunch.jpg', 'https://www.acefitness.org/education-and-resources/lifestyle/exercise-library/52/crunch/'), ('Push-up with Single-leg Raise', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/exercise%20Images/single-leg-raise.jpg', 'https://www.acefitness.org/education-and-resources/lifestyle/exercise-library/42/push-up-with-single-leg-raise/'), ('Front Plank', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/exercise%20Images/front-plank.jpg', 'https://www.acefitness.org/education-and-resources/lifestyle/exercise-library/32/front-plank/'), ('Side Plank', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/exercise%20Images/side-plank.jpg', 'https://www.acefitness.org/education-and-resources/lifestyle/exercise-library/100/side-plank-modified/'), ('Squat Jumps', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/exercise%20Images/jump-squat.jpg', 'https://www.acefitness.org/education-and-resources/lifestyle/exercise-library/116/squat-jumps/'), ('Side Lunge', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/exercise%20Images/side-lunge.jpg', 'https://www.acefitness.org/education-and-resources/lifestyle/exercise-library/50/side-lunge/'), ('Hip Rotations', 'https://raw.githubusercontent.com/CharityBunyon/activateMe/master/activateme.ui/src/assets/exercise%20Images/hip-rotation.jpg', 'https://www.acefitness.org/education-and-resources/lifestyle/exercise-library/110/hip-rotations-push-up-position/')

insert into Food(name, food_type, quantity, calories, points, userId) values('broccoli', 'vegetable', 50, 150, 1 ), ('Almonds', 'Nuts & Seeds', 100, 200, 1), ('bell pepper','vegetable', 50, 150, 2),('Black Beans', 'Legumes', 50, 150, 3),

insert into Food_Category(type, point_multiplier) values('Vegetable', 3),('Fruit', 2), ('Whole Grains', 1), ('Legumes', 3), ('Nuts & Seeds', 2)

insert into Exercise_Category(type, point_multiplier) values('Endurance', 3),('Strength', 3), ('Flexibility', 2), ('Balance', 1)

insert into Exercise([name], categoryType, [time], calories, points, userId) values('weight training', 'strength', 60, 300, 180, 1), ('yoga', 'flexibility', 30, 60, 20, 1), ('running', 'endurance', 30, 90, 45, 2), ('cycling', 'endurance', 30, 90, 45, 2), ('squats', 'strength', 10, 3, 20, 3)

insert into Log(exerciseId, foodId, caloriesFromFood, userId) (1, 1, 50, 1), (2, 2, 200, 1), (2, 2, 200, 2), (3, 3, 50, 3)

CharityBunyon commented 4 years ago

Points query

select 
*
from Badges b
where (select sum(points) as points
from food 
where userId = 9) >= b.pointValue