Hello, would you please help with this for SQL Server? Task 1: Add tags for the
ID: 3737300 • Letter: H
Question
Hello, would you please help with this for SQL Server?
Task 1: Add tags for the allergens included in the nutritionist's list. Implement allergen tags with whichever SQL mechanisms you prefer.
Adds the allergen tagging per recipe as outlined in the document from the nutritionist. Allergens In Recipes: Add tag at beginning of each line below to each of the recipes listed. lactose - Avocado Toast (butter), Cheese and Crackers peanuts - PB & J Bites gluten - Cheese and Crackers, PB & J Bites, Avocado Toast
Task 2: Fix calorie count problems. Write MERGE script to correct the missing information. Use the cals.txt document provided. Cals.txt Calories per Serving per Recipe ------------------------------------ Cheese & Crackers - serving size, 3 crackers with topping - 150 kcal (1 cubic inch cheddar = 69 kcal, would cover 2 crackers; each cracker about 16 kcal) PB & J Bites - serving size, 1/2 sandwich - 163 kcal Avocado Toast - serving size, 1/2 slice - 350 kcal
Explanation / Answer
Please find my answer.
Task1:
why we are using tags?
A)A tag is a custom description that is applied to a node. A tag,once, it can be helpful when we managing nodes
or it providing alternate methods of similar types of information.
First we have to create a tag then we have to use create.Use the create argument to add one or more tags to a node.
following syntax:
$ allergen tag create NODE_NAME[TAG]
Example:
To create tags named lactose,peanuts and gluten,enter:
$ allergen tag create node lactose peanuts gluten
To view the tags for a node named tagname, enter:
syntax:
$ allergen tag list lactose,peanuts and glunten,enter:
if we have to delete tags then Use the delete argument to delete one or more tags from a node.
$ allergen tag delete NODE_NAME [TAG]
To delete tags named lactose,peanuts and glunten enter:
$ allergen tag delete node lactose peanuts
it is asking Y/N
then click to conform Y
task2:
cat 1.Cheese & Crackers 2.PB & J Bites 3.Avocado Toast>> cals.txt
You we can merge multiple txt files from specific folder to one txt file
It will merge all data to one txt file.
1.Create a target table
CREATE TABLE Calories
(
RecipeID INT PRIMARY KEY,
RecipeName VARCHAR(100),
)
GO
2.Insert records into Calories table
INSERT INTO Calories VALUES
(1, 'Cheese & Crackers'),
(2, 'PB & J Bites '),
(3, 'Avocado Toast'),
GO
3.Create asource table
CREATE TABLE UpdatedCalories
(
RecipeID INT PRIMARY KEY,
RecipeName VARCHAR(100),
)
GO
SELECT * FROM Calories
SELECT * FROM UpdatedCalories
GO
MERGE Calories AS TARGET
USING UpdatedProducts AS SOURCE
ON (TARGET. RecipeID = SOURCE. RecipeID)
When records are matched, update the records if there is any change
WHEN MATCHED AND TARGET. RecipeName <> SOURCE. RecipeName
UPDATE SET TARGET. RecipeName = SOURCE. RecipeName,
//When no records are matched, insert the records from source table to target table
WHEN NOT MATCHED BY TARGET THEN
INSERT ( RecipeID, RecipeName)
VALUES (SOURCE. RecipeID, SOURCE. RecipeName)
When there is a row that exists in target table and same record does not exist in source table
then delete this record from target table
WHEN NOT MATCHED BY SOURCE THEN
DELETE
OUTPUT that returns one of three
//values for each row: 'INSERT','UPDATE',or 'DELETE',
DELETED. RecipeID AS Target RecipeID,
DELETED. RecipeName AS Target RecipeName,
INSERTED. RecipeID AS Source RecipeID,
INSERTED. RecipeName AS Source RecipeName,
SELECT @@ROWCOUNT;
GO
Please rate my answer if it helped you!!
id lactose peanuts glunten 1 Avocado Toast (butter) PB &J Bites Cheese 2 Cheese Crackers 3 Crackers PB & J Bites 4 Avocado ToastRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.