首页 > 数据库 >DAT 560G: Database Design and SQL

DAT 560G: Database Design and SQL

时间:2024-09-20 17:45:19浏览次数:8  
标签:city 560G disaster SQL response DAT manager team disasters

DAT 560G: Database Design and SQL

Fall 2024, Mini A

Assignment #3: SQL Part 2

Instructions

1. This is an individual assignment. You may not discuss your approach to solving these questions with anyone (or Generative AI), other than the instructor or TA.

2. Please include only your Student ID on the submission.

3. The only allowed material is:

a. Class notes

b. Content posted on the LMS

c. Textbook

4. You are not permitted to use other online resources.

5. There will be TA office hours. See the course schedule.

Background

The North American Disasters Database is a comprehensive repository designed to document and analyze various disasters that have occurred across North America. From natural calamities such as hurricanes, earthquakes, and wildfires to human-made incidents like industrial accidents and environmental crises, this database aims to provide a detailed record of significant events that have impacted North America.

Types relation contains the following information about each type of disaster in the database:

• Type of each disaster. This is the primary key.

• Natural indicates whether this type of disaster is natural or caused by people (man-made)

• Modewhat causes this type of disaster

• Size: the typical size of the disaster, in square miles

• Frequency: Every how many years the event can be expected.

Types (Type, Natural, Mode, Size, Frequency)

Places relation describes the cities where disasters may occur. It captures information about the cities and states where disasters occur, including geographic, demographic, and economic data. NOT all cities have disasters. It includes the following attributes.

• City: Name of the city. This is the primary key.

• State: Name of the state.

• Region: Name of the region within the US.

• Size: Geographic size of the city in square miles.

• Population: Number of people living in the city.

• Income: Average income of the residents in the city, in dollars.

• Homeowners: Percentage of houses that are owned by the occupants rather than rented.

• Budget: The city's annual budget.

• FoundingDate: The date when the city was founded.

• ManagerFirstName: The first name of the emergency manager in the city.

• ManagerLastName: The lastname of the emergency manager in the city.

• Gender: Gender of the emergency manager.

• Salary: Annual salary of the emergency manager.

• StartingDate: The date when the emergency manager started their position.

Places (City, State, Region, Size, Population, Income, Homeowners, Budget, FoundingDate,

ManagerFirstName, ManagerLastName, Gender, Salary, StartingDate, Environmental, Quality)

Teams relation records details about the response 代 写DAT 560G: Database Design and SQL teams, including their budget, size, and the demographics of their members. There can be more than one response team for a city. If a city has disasters, then it must have at least one team. Some of the cities that do not have disasters may not have any response teams.

• Team: Unique identifier for the response team.

• City: Name of the city where the response team is based. This is a foreign key, to the places relation

• Organization: The organization to which the response team belongs.

• Budget: The annual budget of the response team, in dollars

• FirstDate: The date when the response team was first established.

• Employees: The number of employees in the response team.

• ManagerFirstName: The first name of the manager of the response team.

• ManagerLastName: The lastname of the manager of the response team.

• Gender: Gender of the manager.

• Salary: Annual salary of the manager in dollars.

• Female: Percent of the team that is female.

• Minority: Percent of the team that is minorities.

• ServiceArea: This is the part of the city that this team serves. Can have values of either: All, North, South, East, West.

Teams (TeamCity, Organization, Budget, FirstDate, Employees, ManagerFirstName, ManagerLastName, Gender, Salary, Female, Minority, ServiceArea)

TeamSkills relation lists the specific skills possessed by these teams, providing insight into their capabilities. Not all teams need to have skills. Some teams can have several skills. Different teams will have different numbers of skills.

• Team: Unique identifier for the response team. This is a foreign key.

• Skill: Specific skill possessed by the response team. This is part of the multi-attribute key

TeamSkills (TeamSkill)

Disasters relation documents the details of each disaster event, including the type, location, response team involved, and the impact in terms of duration, casualties, property damage, and the number of responders. It includes the following information:

• Type: The type of disaster. Foreign Key that refers to the Type in the CauseTypes table.

• City: Name of the city where the disaster occurred. This is a foreign Key referring to Places.

• Team: Unique identifier for the response team that responded to the disaster. Foreign key referring to Teams relation.

• Name: A unique name or identifier for the disaster. This is part of the multi-attribute key.

• Date: The date when the disaster occurred.

• Year: The year when the disaster occurred.

• Month: The month when the disaster occurred.

• Duration: The duration of the disaster, in hours.

• Casualties: The number of casualties resulting from the disaster.

• PropertyDamage: The estimated property damage caused by the disaster, in US dollars.

• Responders: The number of responders involved in addressing the disaster.

Disasters (TypeCityTeamName, Date, Duration, Casualties, PropertyDamage, Responders, Year, Month)

Relations

Types (Type, Natural, Mode, Size, Frequency)

Places (City, State, Region, Size, Population, Income, Homeowners, Budget, FoundingDate,

ManagerFirstName, ManagerLastName, Gender, Salary, StartingDate, Environmental, Quality)

Teams (TeamCity,    Organization,   Budget,    FirstDate,   Employees,    ManagerFirstName,

ManagerLastName, Gender, Salary, Female, Minority, ServiceArea)

TeamSkills (Team, Skill)

Disasters (TypeCityTeam,  Name, Date,  Duration, Casualties, PropertyDamage, Responders,

Year, Month)

Assignment

Each of these questions is 10 points. Submit answers to these online on Canvas, by 6 am the day of the lab. They are automatically graded.

1)   Find all cities that have more than 2 disasters. List the cities that have the most disasters first down to those who only have the fewest.

2) List all of the skills related to teams that responded to Dam failures after 2010Please only list the skill once.

3)   In order to compare gender differences in manager salaries, please list the average salary for team managers by genderOnly include teams with average budgets greater than $5 million for teams established after 2010, and not in the state of CaliforniaDo not include teams with null values for their team managersgender.

4) In order to find an experienced team manager with spills,find all managers who have experience with 2 or more disasters with an oil spill, train spill, or truck spill. Include the manager’sfirst and lastnameteamand the number of disasters the manager has overseen. Sort the list with the most experienced first.

5) List the cities in this database that have NOT been affected by disasters.

6) Find the types of disasters with six or fewer occurrences in this database.

Each of these questions is 5 points. Submit answers to these on Canvas before the next lab session. They will be graded by TAs.

For each questionsubmit your SQL code and a screenshot of the resultsIf the results are too long, partial results are fineInclude relevant attributes for each resultto explain that the result is correct. Do NOT include many unnecessary attributes. Do NOT use SELECT *.

7) Find the cities with less than 5 disastersInclude the populationstateregion, and number of disasters.

8)   Is there a city that has a population over 900,000 and has had both natural as well as man-made disasters? List it then. In your query results, make sure each row contains a unique city/Natural- type combination. Also list the city name and population.

9) Are there any pairs of teams that have responded to the same type of disaster and the same city? List team pairings only once and include the city name in your results.

10) Find teams with less than 150 employees and more than 70 femalesList the team, the number of disastersand the average number of responders.

11) Find cities with more than two disasters, populations greater than 500,000, and disaster recovery teams led by female managersList the name of the city only once in your results.

12) Please identify how many disasters happened in each city ofCalifornia that occurred in October or January, had populations LESS THAN 500,000, and casualties above 900. Include the city, number of casualtiesthe populationand the date of the disaster in your answer.

13) Find the minimum population and the average budget for states with less than five disastersList the statenumber of disastersminimum populationand average budgetorder by state name.

14) How much time did you spend on this assignment?

 

 

 

 

标签:city,560G,disaster,SQL,response,DAT,manager,team,disasters
From: https://www.cnblogs.com/WX-codinghelp/p/18422958

相关文章

  • 基于JSP+SQL英语在线考试系统毕业设计整套的计算机毕设源码+论文
    摘要伴随着Internet技术在各个领域的广泛应用,当今社会已经进入信息时代,信息技术革命使社会的各个领域都发生了翻天覆地的变化,计算机,网络技术也渗透到了学校的日常管理当中去。而且网络化的管理也适合现在人的生活需求。在线考试系统以其较高的实用功能、高效率的管理手段深受各......
  • 时代变了,MySQL 早已不是最流行的数据库了
    以下文章来源于古时的风筝,作者风筝在StackOverflow上看到2024年技术趋势,关于数据库的部分,PostgreSQL是开发人员使用最多的数据库,超过MySQL了。虽然在国内好像不是这样。PostgreSQL在2018年的开发者调查中首次亮相,当时有33%的开发者正在使用它。而当年最受欢迎的还是MySQ......
  • oracle常用后台进程及sql语句执行流程
    1.checkpoint功能:减少崩溃恢复crashrecovery时间。检查点可以确保在某个时间点之前的所有事务都写入磁盘,保证数据一致性后台进程ckpt触发,ckpt通知dbwr进程将脏数据库dirtybuffer写出到数据文件上.更新数据文件头及控制文件上的检查点触发条件:数据库一致性关闭、altersystem......
  • WPF DataGrid ItemsSource StaticResource
    //xaml<Windowx:Class="WpfApp386.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.mi......
  • smardaten无代码这么牛逼?逻辑编排不用代码!​
    前言上个月突然刷到smardaten的MES系统案例,从数据对接、应用模块开发、总览大屏、手机APP、OA门户样样搞定,深扒功能才发现什么动态表单和流程都是“小儿科”,现在连前后端逻辑交互都能无码化全搞定。其实市面上低代码/无代码平台也有不少了,但实际上起码要具备逻辑控制和服务编排的能......
  • 04-Mysql索引优化实战一
    示例表CREATETABLE`employees`(`id`int(11)NOTNULLAUTO_INCREMENT,`name`varchar(24)NOTNULLDEFAULT''COMMENT'姓名',`age`int(11)NOTNULLDEFAULT'0'COMMENT'年龄',`position`varchar(20)NOTNULLDEFAULT......
  • Pikachu靶场-SQL注入
    Pikachu靶场数字型注入这里使用的是POST型提交的所以要用抓包工具做(1)判断回显位置语法:id=1unionselect1,2---页面已经显示出有几列了所以没测试(2)判断库名语法:id=1unionselect1,database()---(3)判断表名语法:id=1unionselect1,group_concat(t......
  • 05-Mysql索引优化实战二
    分页查询优化1示例表:2CREATETABLE`employees`(3 `id`int(11)NOTNULLAUTO_INCREMENT,4 `name`varchar(24)NOTNULLDEFAULT''COMMENT'姓名',5 `age`int(11)NOTNULLDEFAULT'0'COMMENT'年龄',6 `position`varchar(20)NOTNUL......
  • docker 安装 mysql 详细教程
    1.打开docker目录cd/usr/local/mkdirdocker2.创建mysql文件夹/usr/local/dockermkdirmysql3.打开mysql文件夹cdmysql/4.创建配置文件目录mkdirconfig5.打开configcdconfig/6.编写配置文件vimmy.cnf[client]#端口号port=3306[mysql]no-be......
  • MyFlash MySQL数据恢复实战案例:将MySQL Docker容器误删除DELETE的数据进行闪回恢复
    创建MySQL容器mkdir-p{data,conf.d}cat>conf.d/log-bin.cnf<<-EOF[mysqld]log_bin=mysql-binlogserver_id=1EOFdockerrm-fmysqldockerrun-d--namemysql-eMYSQL_ROOT_PASSWORD=123456-p3306:3306-v/etc/localtime:/etc/localtime-v./data:......