�京�工大学《数�库系统基础教程》试题和答案 - 百度文库

4£®Ê¹ÓÃSQLÓïÑÔʵÏÖÉÏÊö¼ÆË㣬²¢Ê¹Êä³ö½á¹û²»Öظ´¡£(8) 5£®Ê¹ÓÃSQLÓïÑÔÍê³ÉÏÂÃæµÄ¼ÆË㣺(8)

1) ¼ÆËã2001Äê12ÔÂÇ©¶©µÄËùÓж©µ¥µÄ¶©µ¥ºÅ¡¢Ç©µ¥ÈÕÆÚ¡¢ÏúÊÛÊýÁ¿ºÍÏúÊÛ½ð¶î£¬

²¢°´ÏúÊÛ½ð¶î´ÓСµ½´óÅÅÁС£

2) ¼ÆËã2001Äê12ÔÂÇ©¶©µÄÏúÊÛ½ð¶î×î´óµÄ¶©µ¥ºÅ¡¢ÏúÊÛÔ±ÐÕÃûºÍÏúÊÛ½ð¶î¡£(×¢Òâ

ÀûÓÃÒÑÓвéѯ¶¨ÒåÊÓͼ)

3) ¼ÆËã2001Äê12ÔÂËùÓÐÏúÊÛÔ±µÄÔ±¹¤ºÅ¡¢ÐÕÃû¼°ÆäÏúÊÛ½ð¶î¡£(×¢ÒâʹÓÃÍâÁ¬½Ó£¬

ûÓж©µ¥µÄÏúÊÛÔ±µÄÏúÊÛ½ð¶îӦΪ0)

ÇóÔ±¹¤ºÅΪ¡°S0025¡±µÄÏúÊÛÔ±µÄ²¿Ãž­ÀíµÄÔ±¹¤ºÅ¼°ÆäÐÕÃû

product(maker,model,type) pc(model,speed,ram,hd,cd,price) laptop(model,speed,ram,hd,screen,price) printer(model, color,type,price)

p187 4.1.1

1. What PC models have a speed of at least 150? ¡Çmodel(§Òspeed>=150(PC))

2. Which manufacturers make laptops with a hard disk of at least one gigabyte? ¡Çmaker(§Òhd>=1(Laptop) //¡Çmaker(Laptop Product)

Product)

Product) - ¡Çmaker(§Òhd<1(Laptop) 3. Find the model number and price of all products(of any type) made by manufacturer B. ¡Çmodel,price(§Òmaker=¡¯B¡¯(PC ¡Çmodel,price(§Òmaker=¡¯B¡¯(Laptop ¡Çprinter.model,price(§Òmaker=¡¯B¡¯(Printer Product))¡È

Product))¡È

printer.model=product.model Product))

29

4. Find the model numbers of all color laser printers. ¡Çmodel(§Òtype=¡¯laser¡¯ and color(Printer))

5. Find those manufacturers that sell Laptops, but not PC¡¯s. ¡Çmaker(Laptop Product) - ¡Çmaker(PC Product)

6. Find those hard-disk sizes that occur in two or more PC¡¯s. ¡Çpc1.hd(¦Ñpc1(PC) pc1.model<>pc.model and pc1.hd=pc.hd PC)

7. Find those pairs of PC models that have both the same speed and RAM. ¡Çpc1.model,pc.model(¦Ñpc1(PC) pc1.model

8. Find those manufacturers of at least two different computers (PC¡¯s or laptops) with speeds of at least 133.

P2:=P1:= ¡Çmaker,model(§Òspeed>=133(PC) ¡Çmaker,model(§Òspeed>=133(Laptop) Answer:=¡ÇP1.maker(P1 Product)¡È

Product)

P1.model<>P2.model and P1.maker=P2.maker P2)

9. Find the manufacturer(s) of the computer (PC or laptop) with the highest available speed. P2:=P1:= ¡Çmodel,speed(PC)¡È¡Çmodel,speed(Laptop) Answer:=¡Çmaker(Product (¡Çmodel(P1) - ¡ÇP1.model(P1 P1.speed

10. Find the manufacturers of PC¡¯s with at least three different speeds. P3:=P2:=P1:= ¡Çmaker,speed(Product Answer:=¡ÇP1.maker((P1 PC)

P1.speed

P2.speed

11. Find the manufacturers who sell exactly three different models of PC. P4:=P3:=P2:=P1:= ¡Çmaker,model(Product PC)

30

M1(maker,m1,m2,m3):=¡ÇP1.maker,P1.model,P2.model,P3.model((P1 P2.model and P1.maker=P2.maker P2)

P1.model<

P2.model

Answer:=¡Çmaker(M1) - ¡ÇM1.maker(M1

P253 5.1.3

M1.m3

a) Find the model number, speed, and hard-disk size for all PC¡¯s whose price is under $1600. select model,speed,hd from pc

where price<1600;

b) Do the same as (a), but rename the speed column megahertz and the hd column gigabytes. select model,speed as megahertz, hd as gigabytes from pc where price<1600; c) Find the manufacturers of printers. select maker from product where type=¡¯printer¡¯;

d) Find the model number, memory size, and screen size for laptops costing more than $2000. select model,ram,screen from laptop where price>=2000;

e) Find all the tuples in the Printer relation for color printers. select * from printer where color;

f) Find the model number, speed, and hard-disk size for those PC¡¯s that have either a 6x or 8x CD and a

31

price less than $2000. select model,speed,hd from pc

where price<2000 and (cd=¡¯6x¡¯ or cd=¡¯8x¡¯);

p262 5.2.2

a) Give the manufacturer and speed of laptops with a hard disk of at least one gigabyte? Select laptop.model,maker,speed From laptop, product

Where laptop.model=product.model and hd>1;

b) Find the model number and price of all products (of any type) made by manufacturer B. (Select product.model,price,¡¯pc¡¯ as type1 From product,pc

Where maker=¡¯B¡¯ and product.model=pc.model ) Union

(Select product.model,price,¡¯laptop¡¯ From product,laptop

Where maker=¡¯B¡¯ and product.model=laptop.model ) Union

(Select product.model,price,¡¯printer¡¯ From product,printer

Where maker=¡¯B¡¯ and product.model=printer.model ) c) Find those manufacturers that sell Laptops, but not PC¡¯s. Select maker From product,laptop

Where product.model=laptop.model and maker not in (

32

ÁªÏµ¿Í·þ£º779662525#qq.com(#Ìæ»»Îª@)