欢迎来到冰点文库! | 帮助中心 分享价值,成长自我!
冰点文库
全部分类
  • 临时分类>
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • ImageVerifierCode 换一换
    首页 冰点文库 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    数据库第六章答案.docx

    • 资源ID:6676914       资源大小:28.37KB        全文页数:71页
    • 资源格式: DOCX        下载积分:3金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要3金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    数据库第六章答案.docx

    1、数据库第六章答案第六章6.1.1Attributes must be separated by commas. Thus here B is an alias of A.6.1.2a)SELECT address AS Studio_AddressFROM StudioWHERE NAME = MGM;b)SELECT birthdate AS Star_BirthdateFROM MovieStarWHERE name = Sandra Bullock;c)SELECT starNameFROM StarsInWHERE movieYear = 1980 OR movieTitle LIKE

    2、 %Love%;However, above query will also return words that have the substring Love e.g. Lover. Below query will only return movies that have title containing the word Love. SELECT starNameFROM StarsInWHERE movieYear = 1980 OR movieTitle LIKE Love % OR movieTitle LIKE % Love % OR movieTitle LIKE % Love

    3、 OR movieTitle = Love;d)SELECT name AS Exec_NameFROM MovieExecWHERE netWorth = 10000000;e)SELECT name AS Star_NameFROM movieStarWHERE gender = M OR address LIKE % Malibu %;6.1.3a)SELECT model, speed, hdFROM PCWHERE price 1000 ;MODEL SPEED HD- - -1002 2.10 2501003 1.42 801004 2.80 2501005 3.20 250100

    4、7 2.20 2001008 2.20 2501009 2.00 2501010 2.80 3001011 1.86 1601012 2.80 1601013 3.06 80 11 record(s) selected. b)SELECT model , speed AS gigahertz, hd AS gigabytesFROM PCWHERE price 1500 ;MODEL RAM SCREEN- - -2001 2048 20.12005 1024 17.02006 2048 15.42010 2048 15.4 4 record(s) selected. e)SELECT *FR

    5、OM PrinterWHERE color ;MODEL CASE TYPE PRICE- - - -3001 TRUE ink-jet 993003 TRUE laser 9993004 TRUE ink-jet 1203006 TRUE ink-jet 1003007 TRUE laser 200 5 record(s) selected. Note: Implementation of Boolean type is optional in SQL standard (feature ID T031). PostgreSQL has implementation similar to a

    6、bove example. Other DBMS provide equivalent support. E.g. In DB2 the column type can be declare as SMALLINT with CONSTRAINT that the value can be 0 or 1. The result can be returned as Boolean type CHAR using CASE.CREATE TABLE Printer ( model CHAR(4) UNIQUE NOT NULL, color SMALLINT , type VARCHAR(8)

    7、, price SMALLINT , CONSTRAINT Printer_ISCOLOR CHECK(color IN(0,1) );SELECT model, CASE color WHEN 1 THEN TRUE WHEN 0 THEN FALSE ELSE ERROR END CASE , type, price FROM Printer WHERE color = 1;f)SELECT model, hdFROM PCWHERE speed = 3.2 AND price = 10 ;CLASS COUNTRY- -Tennessee USA 1 record(s) selected

    8、. b)SELECT name AS shipNameFROM ShipsWHERE launched 1918 ;SHIPNAME-HarunaHieiKirishimaKongoRamilliesRenownRepulseResolutionRevengeRoyal OakRoyal Sovereign 11 record(s) selected. c)SELECT ship AS shipName, battleFROM OutcomesWHERE result = sunk ;SHIPNAME BATTLE- -Arizona Pearl HarborBismark Denmark S

    9、traitFuso Surigao StraitHood Denmark StraitKirishima GuadalcanalScharnhorst North CapeYamashiro Surigao Strait 7 record(s) selected. d)SELECT name AS shipNameFROM ShipsWHERE name = class ; SHIPNAME-IowaKongoNorth CarolinaRenownRevengeYamato 6 record(s) selected. e)SELECT name AS shipNameFROM ShipsWH

    10、ERE name LIKE R%;SHIPNAME-RamilliesRenownRepulseResolutionRevengeRoyal OakRoyal Sovereign 7 record(s) selected. Note: As mentioned in exercise 2.4.3, there are some dangling pointers and to retrieve all ships a UNION of Ships and Outcomes is required.Below query returns 8 rows including ship named R

    11、odney.SELECT name AS shipNameFROM ShipsWHERE name LIKE R%UNIONSELECT ship AS shipNameFROM OutcomesWHERE ship LIKE R%; f) Only using a filter like % % % will incorrectly match name such as a b since % can match any sequence of 0 or more characters.SELECT name AS shipNameFROM ShipsWHERE name LIKE _% _

    12、% _% ;SHIPNAME- 0 record(s) selected. Note: As in (e), UNION with results from Outcomes.SELECT name AS shipNameFROM ShipsWHERE name LIKE _% _% _%UNIONSELECT ship AS shipNameFROM OutcomesWHERE ship LIKE _% _% _% ;SHIPNAME-Duke of YorkKing George VPrince of Wales 3 record(s) selected. 6.1.5a)The resul

    13、ting expression is false when neither of (a=10) or (b=20) is TRUE. a = 10 b = 20 a = 10 OR b = 20 NULL TRUE TRUE TRUE NULL TRUE FALSE TRUE TRUE TRUE FALSE TRUE TRUE TRUE TRUE b)The resulting expression is only TRUE when both (a=10) and (b=20) are TRUE. a = 10 b = 20 a = 10 AND b = 20 TRUE TRUE TRUEc

    14、)The expression is always TRUE unless a is NULL. a = 10 a = 10 AND b = 20 TRUE FALSE TRUE FALSE TRUE TRUE d)The expression is TRUE when a=b except when the values are NULL. a b a = b NOT NULL NOT NULL TRUE when a=b; else FALSE e)Like in (d), the expression is TRUE when a=b except when the values are

    15、 NULL. a b a = b NOT NULL NOT NULL TRUE when a M2.length AND M2.title =Gone With the Wind ; e)SELECT X1.name AS execNameFROM MovieExec X1, MovieExec X2WHERE XWorth XWorth AND X2.name = Merv Griffin ;6.2.2a)SELECT R.maker AS manufacturer, L.speed AS gigahertzFROM Product R, Laptop LWHERE L.hd = 30 AN

    16、D R.model = L.model ;MANUFACTURER GIGAHERTZ- -A 2.00A 2.16A 2.00B 1.83E 2.00E 1.73E 1.80F 1.60F 1.60G 2.00 10 record(s) selected. b)SELECT R.model, P.priceFROM Product R, PC PWHERE R.maker = B AND R.model = P.modelUNIONSELECT R.model, L.priceFROM Product R, Laptop LWHERE R.maker = B AND R.model = L.

    17、modelUNIONSELECT R.model, T.priceFROM Product R, Printer TWHERE R.maker = B AND R.model = T.model ; MODEL PRICE- -1004 6491005 6301006 10492007 1429 4 record(s) selected. c)SELECT R.makerFROM Product R, Laptop LWHERE R.model = L.modelEXCEPTSELECT R.makerFROM Product R, PC PWHERE R.model = P.model ;M

    18、AKER-FG 2 record(s) selected. d)SELECT DISTINCT P1.hdFROM PC P1, PC P2WHERE P1.hd =P2.hd AND P1.model P2.model ;Alternate Answer:SELECT DISTINCT P.hdFROM PC PGROUP BY P.hdHAVING COUNT(P.model) = 2 ; e)SELECT P1.model, P2.modelFROM PC P1, PC P2WHERE P1.speed = P2.speed AND P1.ram = P2.ram AND P1.mode

    19、l = 3.0 AND P.model=R.model UNION SELECT maker, R.model FROM Laptop L, Product R WHERE speed = 3.0 AND L.model=R.model ) MGROUP BY M.makerHAVING COUNT(M.model) = 2 ;MAKER-B 1 record(s) selected. 6.2.3a)SELECT S.nameFROM Ships S, Classes CWHERE S.class = C.class AND C.displacement 35000;NAME-IowaMiss

    20、ouriMusashiNew JerseyNorth CarolinaWashingtonWisconsinYamato 8 record(s) selected. b)SELECT S.name , C.displacement, C.numGunsFROM Ships S , Outcomes O, Classes CWHERE S.name = O.ship AND S.class = C.class AND O.battle = Guadalcanal ; NAME DISPLACEMENT NUMGUNS- - -Kirishima 32000 8Washington 37000 9

    21、 2 record(s) selected. Note:South Dakota was also engaged in battle of Guadalcanal but not chosen since it is not in Ships table(Hence, no information regarding its Class is available).c)SELECT name shipNameFROM ShipsUNIONSELECT ship shipNameFROM Outcomes ;SHIPNAME-ArizonaBismarkCaliforniaDuke of Yo

    22、rkFusoHarunaHieiHoodIowaKing George VKirishimaKongoMissouriMusashiNew JerseyNorth CarolinaPrince of WalesRamilliesRenownRepulseResolutionRevengeRodneyRoyal OakRoyal SovereignScharnhorstSouth DakotaTenneseeTennesseeWashingtonWest VirginiaWisconsinYamashiroYamato 34 record(s) selected.d)SELECT C1.coun

    23、tryFROM Classes C1, Classes C2WHERE C1.country = C2.country AND C1.type = bb AND C2.type = bc ;COUNTRY-Gt. BritainJapan 2 record(s) selected. e)SELECT O1.shipFROM Outcomes O1, Battles B1WHERE O1.battle = B1.name AND O1.result = damaged AND EXISTS (SELECT B2.date FROM Outcomes O2, Battles B2 WHERE O2.battle=B2.name AND O1.ship = O2.ship AND B1.date 3;SELECT O.battleFROM Ships S , Classes C, Outcomes OWHERE C.Cla


    注意事项

    本文(数据库第六章答案.docx)为本站会员主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2023 冰点文库 网站版权所有

    经营许可证编号:鄂ICP备19020893号-2


    收起
    展开