当前位置:网站首页>Final examination questions of Database Principles
Final examination questions of Database Principles
2022-06-22 04:41:00 【University of science and technology Yunju】
score |
Four 、 Practical questions ( This topic consists of 1 Little topic , common 18 branch )
1、 Suppose that a factory producing parts has several workshops , Each workshop processes several kinds of parts , Each part is processed in a certain workshop ; The attribute of a workshop has a workshop name ( only )、 Telephone ; Part attributes have part numbers 、 Part name ; The parts are made of different raw materials , The raw materials used for different parts can be the same , It could be different ; The attribute of making has the making time ; The properties of materials include material number and supplier . Please draw the corresponding E-R chart , And write the corresponding relationship pattern .
(1)E-R chart ( Mark the contact type )(10 branch )

(2) The transformed relational schema ( It is required to achieve Third normal form , Primary key and Foreign keys You can use A symbol mark or After the relational mode, the text expresses )(8 branch )
Relationship model

5、 ... and 、SQL Practical questions ( This topic consists of 2 Little topic , The first 1 Little topic 27 branch , The first 2 Little topic 5 branch , common 32 branch )
1、 There is an existing one named “HouseSelling” The database of , There are three tables under this database , As required , Write the corresponding SQL sentence .( common 6 A little question , among 1-3 Each question 4 branch ,4-6 Each question 5 branch , common 27 branch )
(1) Listings (houses),“ House number ” Primary key .
(2) Salesman list (salesman),“ Salesman number ” Primary key .
(3) Sales list (sales),“ Salesman number , House number ” Primary key , Both the salesperson number and the house source number are foreign keys .
explain : In the following data sheets “()” Part is field type ,SQL When you write a statement Please write the field name correctly , If the field name is misspelled, points will be deducted .
houses surface
House number (char(12)) | Community name (char(20) | area (float) | The total price (decimal(10,2)) | floor (int) | General floor (int) | Completion date (date) | Number of rooms (int) |
100-5-202 | Tianhua garden | 55.90 | 1000000.00 | 2 | 15 | 2010.7.1 | 1 |
111-10-401 | Zhongcheng Pavilion | 85.73 | 1700000.00 | 4 | 5 | 2013.12.2 | 2 |
100-2-801 | Shiyuan City | 110.21 | 2298900.00 | 8 | 12 | 2015.9.1 | 3 |
233-1-302 | Philanthropic predestination | 79.27 | 1595000.00 | 3 | 6 | 2018.7.1 | 2 |
100-5-302 | Tianhua garden | 55.90 | 1050000.00 | 2 | 15 | 2010.7.1 | 1 |
111-10-501 | Zhongcheng Pavilion | 85.73 | 1760000.00 | 4 | 5 | 2013.12.2 | 2 |
100-2-1001 | Shiyuan City | 110.21 | 2198900.00 | 8 | 12 | 2015.9.1 | 3 |
233-1-602 | Philanthropic predestination | 79.27 | 1545000.00 | 3 | 6 | 2018.7.1 | 2 |
sales surface
Salesman number (char(7)) | House number (char(12)) | Sales date (date) |
10002 | 111-10-401 | 2014-5-3 |
12010 | 233-1-302 | 2018-10-2 |
12003 | 233-1-602 | 2018-9-10 |
10002 | 100-5-302 | 2011-1-2 |
salesman surface
Salesman number (char(7)) | full name (char(10) | Gender (char(2) | Telephone (char(11)) |
10002 | Sun Hua | male | 13502100210 |
12003 | Zhang Guihua | Woman | 13502100211 |
12010 | Liu Yuanhang | male | 13502100212 |
15079 | Wangxingxin | male | 13502100213 |
- Query all in 2015 Information on houses built in and after , Include listing number 、 Community name 、 area 、 The total price 、 Number of rooms .
Select House number , Community name , area , The total price , Number of rooms from houses Where year( Completion date )>=2015
- stay salesman Insert a record in the table , full name : still , male , The number is 20001, The mobile number is 15120136490.
Insert into salesman values (‘20001‘,‘ still ‘,‘ male ‘,‘15120136490‘)
- The number is “10002” The salesperson changed his mobile phone number for some reason , Please be there. salesman Change its mobile phone number to “18902016688”.
Update salesman set Telephone =‘18902016688‘ where Salesman number =‘10002‘
- Delete the salesperson information without sales performance .
Delete from salesman where Salesman number not in (Select distinct Salesman number from sales)
- Query the information about the houses sold by the female salesperson , Including name, 、 House number 、 community 、 Area and total price .
Select full name , House number , community , area , The total price from houses h,salesman sm,sales ss
Where h. House number =ss. House number and sm. Salesman number =ss. Salesman number and Gender =‘ Woman ‘
- Count the number of houses in each community , Display the name of the community and the number of houses .
Select Community name ,count(*) AS Number of houses available from houses group by Community name
2、 According to the corresponding requirements , Write the corresponding T-SQL sentence , Complete related functions .( common 2 Little topic , please Choose any question Answer , common 5 branch )
According to the previous question “HouseSelling” Complete the following two questions , Choose any question Can be completed .
- Establish a stored procedure to count the historical sales performance of salespeople p_sales_smno( The salesperson number is the input parameter ), Display the salesperson's name 、 House number 、 Sales date 、 Total price information , And call execution ( The query salesperson number is 10002 Historical sales performance ).
stored procedure :
Create proc p_sales_snmo @smno char(7) AS
Select full name , House number , Sales date , The total price from houses h,salesman sm, sales ss
Where h. House number =ss. House number and sm. Salesman number =ss. Salesman number
And Salesman number [email protected]
Calls to perform :
execute p_sales_smno ‘10002‘
- Set up triggers t_house_update, When updating the listing information , The total price should be within 100 Wan to 300 Between ten thousand , otherwise , Tips “ The price is out of range ”, And cancel the relevant operation .
Create trigger t_house_update on houses After Update AS
If not exists(select * from inserted where The total price between 1000000 and 3000000)
Begin
Rooback;
Print ‘ The total price is out of range ‘;
End
边栏推荐
- Cloud native enthusiast weekly: Chaos mesh upgraded to CNCF incubation project
- The beta version of move protocol is stable, and it is temporarily decided to expand the scale of the prize pool
- Interaction between C language and Lua (practice 3)
- On the income of enterprise executives
- 音频帧大小的计算
- 软考2022年下半年考试科目安排
- Customized plug-ins in Cordova project -- plug-in creation process
- 《数据库原理》期末考试题
- Redis master-slave replication
- 【故障诊断】切图代码切不出来,slide.read_region不运行,但程序不报错
猜你喜欢

套用这套模板,玩转周报、月报、年报更省事

Redis master-slave replication

Disturbed when programmers are programming? Daily anecdotes

The best time to climb a ladder & sell shares (notes of the runner)

About SSM integration, this is enough ~ (nanny level hands-on tutorial)

网页设计与制作期末大作业报告——大学生线上花店

Ora-15063: ASM discovered an insufficient number of disks for diskgroup

中闽在线:以“积分”为纽带 共享线上渠道资源

Introduction to AWS elastic Beanstalk

LeetCode 437. Path sum III - binary tree series question 13
随机推荐
浏览器--常用的搜索操作符大全--使用/实例
cadence allegro 17. X conversion tool for downgrading to 16.6
Calculation of audio frame size
Interaction between C language and Lua (practice 3)
Is the Guoyuan futures account reliable? How can a novice safely open an account?
Use echart to draw 3D pie chart, dashboard and battery diagram
System V IPC and POSIX IPC
LeetCode 437. Path sum III - binary tree series question 13
Thinkphp 的sesssion在同一个控制器不同的方法无法获取session的原因和对策
每日一问:ArrayList和LinkedList的区别
The beta version of move protocol is stable, and it is temporarily decided to expand the scale of the prize pool
学信网的头像下载下来太小的处理方法
ORA-15063: ASM discovered an insufficient number of disks for diskgroup 恢复---惜分飞
How to use dataX to update the data in the downstream Oracle database with the update semantics
Design and implementation of ks004 based on SSH address book system
Lightweight CNN design skills
torch DDP Training
mongo模糊查詢,帶有特殊字符需要轉義,再去查詢
Customized plug-ins in Cordova project -- plug-in creation process
mongo模糊查询,带有特殊字符需要转义,再去查询