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

Bài tập câu hỏi trắc nghiệm SQL

2 3,2K 20
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

Tiêu đề Bài Tập Câu Hỏi Trắc Nghiệm SQL
Thể loại exercise
Định dạng
Số trang 2
Dung lượng 24,53 KB

Nội dung

ONLINE CONTESTS system organises contests on various topics. Each contest on a particular topic has a set of 5 questions to be answered, and is sponsored by a company. The following tables are maintained within database by the system :

Trang 1

Exercise 1

Q1

ONLINE CONTESTS system organises contests on various topics Each contest on a

particular topic has a set of 5 questions to be answered, and is sponsored by a company

The following tables are maintained within database by the system :

Table : CONTEST Table : COMPANY

contest_cd

contest_des

clos_dt

comp_cd

Contest code

Name and description

Closing date

Sponsoring company code

comp_cd comp_nm address tel_no cont_per

Company code (PK) Company name

Address

Telephone number

Contact person’s name

Table : QUES_ANS Table : CON_ANS

contest_cd

ques1

ans1

ques2

ans2

ques3

ans3

ques4

ans4

ques5

ans5

Contest code

Question 1

Answer 1

Question 2

Answer 2

Question 3

Answer 3

Question 4

Answer 4

Question 5

Answer 5

con_cd contest_cd ans1 ans2 ans3 ans4 ans5

Contestant code

Contest code

Answer 1

Answer 2

Answer 3

Answer 4

Answer 5

Table : CONTESTANT

Column Description

con_cd

con_nm

e_mail

dt_of_entry

Contestant code

Contestant name

E-mail address

Date of entry

a) Create tables CONTEST, COMPANY, QUES_ANS, CON_ANS, and CONTESTANT b) In COMPANY table, column comp_cd, system generated sequential values like

1000,1002,1004,1006, … will be added at the time of record addition

c) Add few required records to those tables

Notice: PK: Primary key

Trang 2

Q2

Use the tables in Question 1 to state T-SQL command / query for each of the following:

a) Set the foreign key constraint for the company code in the CONTEST table

b) Display the unique names of contestants having “hotmail.com” or “yahoo.com” as part of their e-mail address

c) Display the details of contests having closing date as 31st August ’2001, which have not been attempted by any contestant

d) Remove the details of contests from the CONTEST, QUES-ANS and CON_ANS tables, which had closing date before 1st January ’2001

e) Display Contestcode, contestantcode, contestantname and total no of contestant for each contestcode Display the total no of contestants also for all the contests

f) Create a view MAX_ENTRY that stores the contest details of contests for which more than

5 contestant entries have been received

g) Display the company code, name and number of contests sponsored by the company that has sponsored the highest number of contests

Q3 :

Create a trigger, named trig_Del_CONTEST, which will be invoked when a contest

being deleted from the CONTEST table

Before deletion, the contest_cd, contest_des, comp_cd, dt_of_withdraw will be

stored in a CONTEST_HIST table At the same time it will be deleting all

corresponding records from QUES_ANS and CON_ANS tables

CONTEST_HIST table has the structure as follows :

Table : CONTEST_HIST

Column Description

contest_cd

contest_des

comp_cd

dt_of_withdraw

Contest code

Name and description

Company code Date of deletion

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

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w