db sql code-2
db sql code-2
GO
USE CulinaryBook;
GO
Cuisine NVARCHAR(100),
PrepTime INT,
CookTime INT,
Servings INT,
Instructions NVARCHAR(MAX),
Difficulty NVARCHAR(50),
Calories INT
);
GO
Measurement NVARCHAR(50),
);
GO
);
GO
Surname NVARCHAR(100),
Bio NVARCHAR(MAX),
YouTubeChannel NVARCHAR(255)
);
GO
);
GO,
INSERT
VALUES
VALUES
('Jamie', 'Oliver', 'Celebrity chef known for his focus on healthy eating and easy-to-make recipes.',
'https://www.youtube.com/user/jamieoliver'),
('Gordon', 'Ramsay', 'Chef, restaurateur, and television personality known for his fiery temper and high
standards in the kitchen.', 'https://www.youtube.com/user/gordonramsay'),
('Nigella', 'Lawson', 'Food writer and broadcaster known for her comforting home cooking style.'),
('Rachael', 'Ray', 'Television personality and celebrity chef who hosts a popular talk show and cooking
program.', 'https://www.youtube.com/user/rachaelray');
INSERT INTO Recipes (Title, Cuisine, PrepTime, CookTime, Servings, Instructions, Difficulty, Calories)
VALUES
('Chocolate Chip Cookies', 'American', 15, 12, 24, 'Preheat oven to 350°F. Mix flour, sugar, and butter.
Add eggs, vanilla extract, and chocolate chips. Bake for 12 minutes.', 'Easy', 250),
('Spaghetti Aglio e Olio', 'Italian', 10, 10, 2, 'Cook spaghetti. Sauté garlic in olive oil, toss with spaghetti,
and garnish with parsley.', 'Easy', 350),
('Beef Wellington', 'British', 45, 60, 4, 'Prepare beef with mushroom duxelles, wrap in puff pastry, and
bake at 400°F for 25-30 minutes.', 'Hard', 800),
('Chicken Alfredo', 'Italian', 20, 20, 4, 'Cook chicken, make alfredo sauce with butter, cream, and
Parmesan cheese. Toss with cooked pasta.', 'Medium', 600);
-- Inserting sample data into RecipeIngredients table (linking recipes and ingredients)
VALUES
(4, 6), -- Chicken Alfredo: Vanilla Extract (optional for the sauce, though it could be used sparingly)
VALUES
QUERIES
FROM Authors
FROM Recipes
4)Y.channel of X author
FROM Authors
FROM Recipes
LAB 5
1)
FROM Recipes r
2)
SELECT r.Title AS RecipeTitle, i.Name AS IngredientName, ri.Quantity, ri.Measurement
FROM Recipes r
3)
FROM Authors a
GROUP BY a.Name;
4_)
FROM Recipes r
ORDER BY r.Cuisine;
5)
FROM Recipes r
6)
FROM Recipes r
JOIN RecipeAuthors ra ON r.RecipeID = ra.RecipeID
7)
FROM Recipes r
8)
FROM Recipes r
ORDER BY r.Cuisine;
9)
FROM Recipes r
10)
FROM Authors a
Group by queries
1)
FROM Authors a
GROUP BY a.Name;
2)
FROM Recipes r
GROUP BY r.Cuisine;
3)
FROM Recipes r
GROUP BY r.Title;
4)
FROM Authors a
5)
FROM Recipes r
GROUP BY r.Difficulty;
6)
FROM Recipes r
GROUP BY r.Cuisine
WITH ROLLUP;
7)
FROM Recipes r
GROUP BY r.Cuisine;
8)
FROM Ingredients i
GROUP BY i.Name;
9)
FROM Authors a
GROUP BY a.Name;
10)
FROM Recipes r
GROUP BY r.Difficulty
WITH ROLLUP;