欢迎来到三一文库! | 帮助中心 三一文库31doc.com 一个上传文档投稿赚钱的网站
三一文库
全部分类
  • 研究报告>
  • 工作总结>
  • 合同范本>
  • 心得体会>
  • 工作报告>
  • 党团相关>
  • 幼儿/小学教育>
  • 高等教育>
  • 经济/贸易/财会>
  • 建筑/环境>
  • 金融/证券>
  • 医学/心理学>
  • ImageVerifierCode 换一换
    首页 三一文库 > 资源分类 > PPT文档下载  

    面向对象数据库答案.ppt

    • 资源ID:3227708       资源大小:204.04KB        全文页数:25页
    • 资源格式: PPT        下载积分:6
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录   微博登录  
    二维码
    微信扫一扫登录
    下载资源需要6
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

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

    面向对象数据库答案.ppt

    高级数据库系统习题解答 (1),第一次作业,7.2 解:第三句有问题,左边为string类型,右边是City类型。 CityOfLA.name := cityOfLA.mayor.spouse.livesIn;,第一次作业,7.4 解:前一种的输出结果为: Donald Duck Mickey Mouse 后一种的输出结果为: 60 60 因为前一种是引用语义,而后一种是复制语义。,第一次作业,7.9 解:(1), (2) 从引用语义考虑,(3), (4) 从复制语义考虑。 (1)(2)执行完毕后, mary.chilaren =joe.children =littleJoe,第一次作业,7.9 解: (3)(4)执行完毕后,betty.children = jimbo, jim.children = 。,第二次作业,8.8 解: surface: 计算表面积。 scale: 按比例放大/缩小Cuboid的尺寸。 center: 返回Cuboid的中心坐标。 diagonal: 计算对角线长度。 minDistance: 计算Vector参数到Cuboid的最短距离。,第二次作业,8.8 解: persistent type Cuboid is public length, width, height, surface, volume, weight, translate, scale, rotate, certer, diagonal, minDistance; body v1, v2, v3, v4, v5, v6, v7, v8 : Vetex; mat : Material; value : float; operations declare surface : float; declare scale : Vertex void code scaleCuboid; declare center : Vertex; declare diagonal: float; declare minDistance : Vertex float code minDistanceCode; ,第二次作业,8.8 解: implementation define surface is return 2.0 * (self.length*self.width + self.length*self.height + self.width*self.height); define scaleCuboid(s) is begin self.v1.scale(s); self.v8.scale(s); end define scaleCuboid;,第二次作业,8.8 解: define center is var c : Vertex; begin c.create; c.x = 0.5 * (self.v1.x + self.v7.x); c.y = 0.5 * (self.v1.y + self.v7.y); c.z = 0.5 * (self.v1.z + self.v7.z); return c; end define certer; define diagonal is return self.v1.distance(self.v7);,第二次作业,8.8 解: define minDistanceCode(v) is var v0; begin /将长方体的6个面无限延伸,可将整个空间分为27个区域 if (v在长方体内部或表面上) return 0; else begin 根据v所在区域,可简单判断出长方体上距v最近的点v0所在 的面/棱/顶点,进而求出v0; return v.distance(v0); end else end deine minDistanceCode; end type Cuboid;,第二次作业,9.1 解: (1)方法一采用1:1关系表示1:N关系,存在较多冗余; 不考虑索引,已知left查询对应的right集时,方法二效果明显好于方法一;已知right查询对应的left时,方法一效果好于方法二。 当插入新关系时,两种方法都无法保证一致性,即原关系1:N的语义约束可能被违反,需要对insert操作做修改,保证每一个Tright实例仅有至多一个对应的Tleft实例。 删除关系时,方法一中直接删除对应的TR实例,方法二中只需修改right集合,直到right集合为空时,才需要删除对应的TR实例。 更新操作由插入删除操作组合而成,不再讨论。 (2)方法一、二的insert操作均需修改,以保证一致性,方法二的delete操作也需要修改。修改思想上边已说明,具体算法不再给出。,第二次作业,9.7 解: 在对象内部使用计数器 对于专用对象,生成实例,置为1,被引用,置为0; 对于依赖对象,引用+1,不再引用-1,为0时删除对象。,第三次作业,10.5 解: 合法的重定义要求: 操作名不变,参数个数不变; 操作的接受者类型是原操作中接受者类型的子类; 操作的返回值类型是原操作返回值的子类; 操作的参数类型是原操作参数类型的超类。 题中的重定义仅满足(1)(2)(3),但违反(4)。ConicalPipe是Pipe的子类而非超类,故不合法。 考虑程序段: var aPipe, anotherPipe : Pipe; aConicalPipe : ConicalPipe; anotherPipe := aConicalPipe; / 可替换性,合法 anotherPipe.connect(aPipe); / 编译通过,执行时动态绑定错误。,第三次作业,10.6 解:继承属性的类型是不能重定义的,必须保持原类型。 (1) 子类中继承属性的类型不能是该类型的子类,即特化不合法。 特化举例: type Person is body name : string; age : int; type Employee supertype Person is body boss : Employee; type Manager supertype Employee is body refine boss : Manager; ,第三次作业,10.6 解:程序段: var anEmp : Employee; aMgr : Manager; aMgr.boss := anEmp; /语法错误 anEmp.boss := aMgr; /可替换性,合法 anEmp.boss.boss := anEmp; /语法检查合法,但有潜在问题 (2) 子类中继承属性的类型不能是该类型的超类,即泛化不合法。 Person和Employee的类型定义同上,Manager类型定义如下: type Manager supertype Employee is body refine boss : Person; 程序段: var aPerson : Person; anEmp : Employee; aMgr : Manager; anEmp.boss := anEmp; /合法 aMgr.boss := anEmp; /可替换性,合法 aMgr.boss.boss := anEmp; /语法错误,第三次作业,10.11 解:略,第三次作业,12.3 解:(1) Polymorph declare member (ListType ) : ListType | ElemType bool; define member (t) is var item : ElemType; begin foreach (item in self) if (item = t) return true; return false; end define member;,第三次作业,12.3 解:(2) Polymorph declare nthmember (ListType ) : ListType | int ElemType; define nthmember (n) is var i : int; item : ElemType; Begin if (n self.length | n 1) return null; i := 0; foreach (item in self) begin i+; if (i = n) return item; endfor end define nthmember;,第三次作业,12.3 解:(3) Polymorph declare substitute (ListType ) : ListType | ElemType, ElemType void; define substitute(old, new) is var item : ElemType; begin foreach (item in self) begin if (item = old) begin self.delete(old); self.insert(new); endif endfor end define substitute;,第三次作业,12.3 解:(4) Polymorph declare sublist(ListType ) : ListType | int, int ListType; define sublist(m, n) is var newlist : ListType; item : ElemType; i : int; begin i := 0; if (i = 1 ,第四次作业,13.5 解:多继承不能很好的表示瑞士军刀的例子 多继承缺点: IS-A 语义不清 方法需要重定义以避免冲突 某个部件不能作为单独的部件使用 单继承多置换: 单独的部件可以作为整个对象来使用,使用灵活,第四次作业,14.8 解: Retrieve all Emps who earn more than their Manager. But note that Managers ara also Emps and may work in their own Dept. select e from e in EMP where e.salary e.worksin.mgr.salary;,第四次作业,14.9 解: Retrieve all Managers of the R,第四次作业,18.1 解:,schema C is subsschema F; subsschema G; end schema C; schema E is subsschema H; subsschema I; end schema E;,schema A is subsschema B; subsschema C; end schema A; schema B is subsschema D; subsschema E; end schema B;,第四次作业,18.2 解: schema B is public S interface type S is ; implementation type T is; end schema B;,

    注意事项

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

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




    经营许可证编号:宁ICP备18001539号-1

    三一文库
    收起
    展开