SQL Query Question) The following image is of a database withthe tables listed (foodname, foodgroup, nutrientname andnutrientamount) {Please ignore any other table, just these 4}The table foodname

匿名用户 最后更新于 2021-11-29 17:10 计算机类Computing

SQL Query Question) The following image is of a database withthe tables listed (foodname, foodgroup, nutrientname andnutrientamount) {Please ignore any other table, just these 4}

The table foodname contains a row foreach food in the database. Each row hasa FoodID, a unique identifier for the food,a FoodGroupID that identifies the groupthis food belongs to, an English (FoodDescription)and a French name (FoodDescriptionF) for thefood.

The group table, foodgroup, containsa FoodGroupID and a name for the groupin both English(FoodGroupName)and French(FoodGroupNameF) (e.g. “Pork Products”).

The nutrient name table, nutrientname,contains rows for each nutrient recorded, for example, fat,protein, and vitamin C. In addition, there is an identifier foreach nutrient, NutrientNameID and the Unit that the nutrient ismeasured in (g, mcg, kCal, etc.).

The final table is the mainone, nutrientamount. It links thetables foodname and nutrientname.For each food, there are multiple rows inthe nutrientamount table, one for eachnutrient. Each entry includes the FoodID,the NutrientNameID and how much of thatnutrient is present.

Kindly write the following SQL queries to retrieve data from theabove database:

  1. List the foods in the database, alphabetically by food name.Only display the first 45 characters of the name. Add the message"Low Nutrient Count" to those foods that have fewer than 80nutrients associated with them and add the message "High NutrientCount" to those foods that have more than 120 nutrients associatedwith them.
  2. Retrieve the food ID and food names of foods that start withthe same 20 characters. Make sure you do not count the same foodtwice. i.e. "CEREAL, CAPTAIN CRUNCH" will match itself, but wedon't want to count that. Sort the results using the food name andfood id.

YIELD NAME YieldID YieldName YieldName YIELD AMOUNT FoodID YieldID YieldAmount YieldDateOfEntry REFUSE NAME RefuselD RefuseName RefuseName REFUSE AMOUNT FoodID Refusel RefuseAmount RefuseDateOfEntry FOOD GROUP FoodGroupID Food Group Code FoodGroupName FoodGroupNameF MEASURE NAME MeasurelD MeasureName MeasureNameF CONVERSION FACTOR FoodID MeasurelD ConversionFactor Value ConvFactor DateOfEntry FOOD NAME FoodID FoodCode FoodGroupID FoodSourceID FoodDescription FoodDescription CountryCode FoodDateOfEntry FoodDateOfPublication ScientificName FOOD SOURCE FoodSourceID FoodSource Code FoodSource Description FoodSource DescriptionF NUTRIENT NAME NutrientNameID NutrientCode NutrientSymbol Unit NutrientName NutrientNameF Tagname Nutrient Decimals NUTRIENT AMOUNT FoodID NutrientNameld Nutrient SourceID Nutrient Value StandardError NumberOfObservation Nutrient DateOfEntry NUTRIENT SOURCE Nutrient SourcelD Nutrient Source Code NutrientSourceDescription NutrientSource DescriptionF

已邀请: