1. Trang chủ
  2. » Công Nghệ Thông Tin

Bài tập ôn tập cơ sở dữ liệu SQL

3 4,6K 37
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 3
Dung lượng 46,75 KB

Nội dung

Exercise 2 1. Create a new database called ‘Flight_Management’ 2. Use SQL Query Analyzer to work w

Trang 1

Exercise 2

1 Create a new database called

‘Flight_Management’

2 Use SQL Query Analyzer to work with Flight_Management database and create a SQL script file follow those steps:

1 Create tables and insert data as follows:

Flight

Column Name Data Type Length Allow Nulls

Flight_details

Column Name Data Type Length Allow Nulls

Class_code char 2

Flight_days

Column Name Data Type Length Allow Nulls

day_code int 4

insert the following data into tables

Flight table

Trang 2

Aircraft_code Aircode Type Source Destination Category Dep_time Journey_hrs

Flight_details

Flight_days table

Aircraft_code day_code

9W01 1

9W01 2

AI01 2

AI02 1

AI03 2

BA01 2

Constraints (Student must use ‘Alter Table’ statement to Apply them)

1 Apply the Default Constraint to the Type column of Flight table with value is Airbus

2 Apply the Primary Key Constraint for Aircraft_code of Flight table, and the

Composite Primary Key Constraint for the Aircraft_code and Class_code of the Flight_details table

3 Create a References Constraint between Flight table and Flight_details table on Aircraft_code named ‘FK_Contr1’

Trang 3

2 Display total number of domestic flight (Category=‘D’)

3 Display flight detail has fly at Monday (day_code =2)

4 Create a view named ‘Flight_List’ as following: (the list must sorted by Aircode, Type, ClassCode, Fare, Daycode)

Aircode Type ClassCode Fare Daycode

5 Modify the view named ‘Flight_List’ such that you can create an index on it (Hint: Add

‘With SchemaBinding’ option)

6 Create an index named ‘indFlight_List’ on the (‘Aircode,’ ClassCode) column of the

‘Flight_List’ view

7 Display flight details that has Fare = 5000

8 Drop References Constraint between Flight table and Flight_details

9 Create an Delete Trigger named ‘tgDeleteAll’ on the Flight table to prevent you from deleting a row has Aircarft_code =’9W01’ and display a notice ‘You can not

delete’

10 Create a stored procedure named ‘spDropFlight’ that accept an Aircode as parameter The stored procedure will delete all Flight which has the Aircode like

parameter

Notes: You must ensure that this action will completely

Ngày đăng: 31/08/2012, 16:33

TỪ KHÓA LIÊN QUAN

w