End-of-term review questions on the principle of database system in Nanjing University of Posts and Telecommunications
Official Niu Niu
Click the link below for the ppt:
http://Link: https://pan.baidu.com/s/1VoIFMQzWheCyfJbj2DpdPg?pwd=dwss Extraction code: dwss
It's too troublesome to put the picture, if you need it, click the link below (free)
Please see the ppt sample questions below:
[Term-end review] 2021-2022 Nanyou database system principle final review questions ppt
Cover:
experimental report
experiment name |
Create database schema and SQL query |
mentor |
Zhu Yunxia |
|||||||
experiment type |
verify |
lab hours |
4 |
Experiment time |
||||||
(1) Familiarize yourself with the operating environment and usage of PostgreSQL through hands-on practice. (2) Master the creation of data tables and the operation of tables. (3) Familiar with the Select-SQL command to query data. |
||||||||||
2. Experimental environment (experimental equipment) Hardware: Microcomputer Software: Windows xp/Windows 7 and PostgreSQL Material: experimental data |
||||||||||
3. Experimental content 1. Create a product database products; Create schema products authorization hr 2. Use the CREATE TABLE statement to create the relational schema of the product database database products: Product (maker, model, type) create table product ( maker char(3), model smallint primary key, type char(10)); PC (model, speed, ram, hd, price) create table pc ( model smallint primary key, speed numeric(3,2), ram int, hd smallint, price int); Laptop (model, speed, ram, hd, screen, price) Create table laptop( Model smallint primary key, Speed numeric(3,2), ram int, hd smallint, Screen numeric(3,1) price smallint); Printer (model, color, type, price) Create table printer ( Model smallint primary key, Color boolean, Type char(10), Price smallint); 3. 采用COPY…FROM…语句将数据装入产品数据库; Copy proudct from ‘D:\data\product.txt’ with delimiter; Copy pc from ‘D:\data\pc.txt’ with delimiter; Copy laptop from ‘D:\data\laptop.txt’ with delimiter; Copy printer from ‘D:\data\printer.txt’ with delimiter; 4. 在产品数据库中用SQL语句完成下列查询: ① 查询速度大于等于3.00的PC型号; Select model,speed from pc where speed > 3.00; ② 查询能生产硬盘容量100GB以上的笔记本电脑的厂商; Select distinct maker from product where model in ( select model from laptop where hd > 100) ③ 查询厂商B生产的所有产品的型号和价格; select * from ( (select model, price from (select * from product where maker='B' ) P1 join PC) union (select model, price from (select * from product where maker='B' ) P2 join Laptop) union (select model, price from (select * from Product where maker='B' ) P3 join Laptop)) ④ 查询所有彩色激光打印机的型号; Select model from printer where type = ‘laser’; ⑤ 查询那些只出售笔记本电脑不出售PC的厂商; select distinct maker from product where maker not in ( Select distinct maker from product where model in(select model from pc) ) and maker in (Select distinct maker from product where model in(select model from laptop) ) ⑥ 查询在两种以上PC机中出现过的硬盘容量。 select hd from pc group by hd having count(*) >= 2 5. 在产品数据库中采用SQL命令完成以下操作: ① 将速度大于等于2的Laptop的价格上调10%; Update Laptop set price = 1.1*price where speed >= 2; ② 在PC表中增加一条新记录:
insert into pc values(1014,4.15,2048,300,800); ③ 删除PC表中hd小于100且price小于500的记录。 Delect from pc where hd <100 and pricr <500; 4. Experimental summary (write down the problems encountered during the experiment and the solutions, and the experience and understanding gained in the process of solving the problems) Question: Can't precisely select the desired attribute in multi-table query ? Solution: Make aliases p1 and p2 for pc and product tables respectively, and use "p1." to find the desired attributes correctly. Experience: I still need to read more books, master the knowledge in the books, and then find out my own shortcomings in actual operation. |