Building #11 is undergoing a major renovation. Implement a query to close all requests from apartments in this building. -- TABLE Apartments +-------+------------+------------+ | AptID | UnitNumber | BuildingID | +-------+------------+------------+ |…
Write a SQL query to get a list of all buildings and the number of open requests (Requests in which status equals 'Open'). -- TABLE Apartments +-------+------------+------------+ | AptID | UnitNumber | BuildingID | +-------+------------+------------+…
Write a SQL query to get a list of tenants who are renting more than one apartment. -- TABLE Apartments +-------+------------+------------+ | AptID | UnitNumber | BuildingID | +-------+------------+------------+ | 101 | A1 | 11 | | 102 | A2 | 12 | |…
15.7 Imagine a simple database storing information for students' grades. Design what this database might look like and provide a SQL query to return a list of the honor roll students (top 10%), sorted by their grade point average. 在一个简化的数据库中我们有三个表,St…
15.6 Draw an entity-relationship diagram for a database with companies, people, and professionals (people who work for companies). 在公司Companies工作的人是专家Proferssionals,所以人和专家是ISA("is a")的关系,每个专家有例如等级,和工作经验和其他从人Person继承来的属性.一个专家一次只能为一个公司工作,而一个公司可以雇佣…
15.5 What is denormalization? Explain the pros and cons. 逆规范化Denormalization是一种通过添加冗余数据的数据库优化技术,可以帮助我们减少关系数据库中耗时的交Join.在一般的规范化的数据库中,我们将数据存在不同的表中是为了减少冗余数据,所以我们会尝试着每条数据在数据库中只有一份. 比如说,在一个规范化的数据库中,我们有Courses表和Teachers表,每个Courses表的一项都会保存teacherID,但是没有teac…
15.4 What are the different types of joins? Please explain how they differ and why certain types are better in certain situations. Join是用来联合两个表的,每个表至少需要有一列是相同的,不同的Join类型会返回不同的结果.我们来看一个例子,有两个表,普通饮料和无卡饮料如下: -- TABLE RegularBeverages +-----------+------…
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that "all hou…
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that "all hou…
There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up (u), down (d), left (l) or right (r), but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction. T…