结构推理 有关产品类(Product)及其子类PC机(PC)的ODL描述如下: Product类有四个属性:型号model、制造商maker、类型type(PC、便携式电脑)、价格price。假设型号对于所有制造商和产品类型都是唯一的。 PC机子类有四个属性:速度speed(指处理器的速度,以兆赫计算)、内存ram容量(以兆字节计算)、硬盘hd容量(以千兆字节算)和光盘驱动器cd速度(以几倍速描述)。 要求: (1)用ODL给出类的说明; (2)用OQL写出下列查询: 1)找出价格在8000元以下的所有PC机型号。 2)找出内存至少64M字节、硬盘至少10G字节的所有PC机的型号。
【正确答案】答: (1) interface Product (extent Products key model) { attribute integer model; attribute strmg maker; attribute strmg type; attribute real price; }; interface PC:PrOduct (extent PCs) { attribute Integer speed; attribute Integer rami attribute Integer hd; attribute string cd }; (2) 1) SELECT p.model FROM PCs p WHERE p.price<8000; 2) SELECT p.model FROM PCs p WHERE p.ram>=64 AND p.hd>=lO;
【答案解析】