Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to SQL Exercises. Exercise 1 Suppose we have data on: – Animal name – Type (eg: bird, fish, mammal) – Speed (kph/mph) – Speed types(eg.

Similar presentations


Presentation on theme: "Introduction to SQL Exercises. Exercise 1 Suppose we have data on: – Animal name – Type (eg: bird, fish, mammal) – Speed (kph/mph) – Speed types(eg."— Presentation transcript:

1 Introduction to SQL Exercises

2

3

4 Exercise 1 Suppose we have data on: – Animal name – Type (eg: bird, fish, mammal) – Speed (kph/mph) – Speed types(eg running, swimming, flying, diving etc) Give a relational database schema for a database with this information

5 Exercise 2 Write the SQL to create tables for: – animalType(typeID, description) – speedType(typeID, description) – animal(name, animalType) – animalSpeed(animalName, speedType, topSpeed)

6 Exercise 3 Write the SQL to: – Insert a speedType with typeID of 1 and description running – Insert a speedType with a typeID of 2 and description diving – Insert an animalSpeed for a running cheetah of 112kph – Insert an animalSpeed for a diving peregrine falcon of 387.2kph

7 Exercise 4 Write the SQL to: – Update the animalSpeed of the cheetah to 113kph – Delete the animalSpeed entry for the peregrine falcon

8 Exercise 5 Write the SQL to: – Select all records and fields from the speedType table – Select all animalNames from the animal table – Select all entries for peregrine falcons from the animalSpeed table – Select all entries for diving peregrine falcons from the animalSpeed table

9


Download ppt "Introduction to SQL Exercises. Exercise 1 Suppose we have data on: – Animal name – Type (eg: bird, fish, mammal) – Speed (kph/mph) – Speed types(eg."

Similar presentations


Ads by Google