INFO20003 Semester 2 2024 2: SQLSQL

Java Python INFO20003 Semester 2, 2024

Assignment 2: SQL

Due: Week 8 - Sunday 15th September 2024, 5:59pm Melbourne Time.

Case: “Slarc” App

“Slarc”: Super Lovely App for Requesting Communications

Description

As fellow Database experts, DOTA2 fans, and enterprising communications fans, you and your classmates have created a new open source version of Teams/Slack called Slarc (inspired by the DOTA2 character and Slack!).

For each user, Slarc records their details such as an ID, a username, an email address, a login mechanism (which is defined strictly as one of the following: Google, Apple, Facebook, GitHub), and a reputation score (which is an integer from 0-100 inclusive, 100 as highly trustworthy and 0 being highly untrustworthy). Users can also upload an image for their avatar.

Users communicate with each other by posting in channels. Each channel has an ID, name, date of creation and optional description. When a user posts in a channel, Slarc tracks the post’s author, content and date of creation. Users can also post a reply to an existing post, or react to a post with an emoji, of which the reaction timestamp is recorded. There is an option for users to send attachments in a post; The system records the file size and the dataURL of the object. Slarc automatically scans each post for any harmful content, such as swearing and not safe for work material, and automatically restricts such posts. Similarly, it scans any attached files for potential viruses and flags the results.

When a user's reputation becomes greater than 80, they can be promoted to become a moderator. Other users will be able to see the date that a moderator was promoted, and their self-description if they choose to write one. Once one becomes a moderator, they can be appointed to moderate channels, usually endorsed by another moderator of the associated channel. Their date of appointment is also stored.

Moderators have the responsibility to ensure that posts in the channel abide by community guidelines. If they come across an inappropriate post or one that is flagged with restricted content, they will need to investigate and report on this case. For each case, the responsible moderator must record the case ID, give a brief explanation of the allegation and decide on whether it requires a consequential disciplinary action. The date of allegation will be automatically recorded. If a moderator decides that there needs to be a consequential action, then they can write down the associated action and its date; they are able to hide any post in the channel.

The Data Model

The Data Model from MySQL Workbench is provided in Figure 1.

FIGURE 1. DATA MODEL FOR SLARC.

Assignment 2 Setup

Please pay special attention to the penalties listed [⚠].

A dataset is provided which you can use when developing your solutions. To set up the dataset, download the file slarc.sql from the Assignment link on Canvas and run it in Workbench. This script. creates the database tables and populates them with data.

The sample dataset provided is a basic example of Slarc deployed for a DOTA2 e-sports community. You may find that you may need to add some more sample data in Workbench to fully test out each and every query.

Note that this dataset is provided for you to experiment with: but it is NOT the same dataset as what your queries will be tested against (the schema will stay the same, but the data itself may be different). This means when designing your queries, you must consider edge cases even if they are not represented in this particular data set.

The script. is designed to run against your account on the Engineering IT server (info20003db.eng.unimelb.edu.au). If you want to install the schema on your own MySQL Server installation, uncomment the lines at the beginning of the script.

⚠ WARNING: Do NOT disable only_full_group_by mode when completing this assignment. This mode is the default and is turned on in all default installs of MySQL workbench, and we’ve added a line to the top of slarc.sql to turn it on every time you run the script. in case you disable it! You can check whether it is turned on using the command `SELECT @@sql_mode`; The command should return a string containing ONLY_FULL_GROUP_BY or ANSI. When testing, our test server WILL have this mode turned on, and if your query fails due to this, you will lose marks.

The SQL Tasks

Please pay special attention to the penalties listed [⚠].

In this section are listed 10 questions for you to answer. Write one (single) SQL statement per question. Each statement must end with a semicolon (;). Subqueries and nesting are allowed with INFO20003 Semester 2, 2024 Assignment 2: SQLSQL in a single SQL statement – however, you may be penalised for writing overly complicated SQL statements.

⚠ WARNING: DO NOT USE VIEWS (or ‘WITH’ statements/common table expressions) OR VARIABLES to answer questions. Penalties apply.

❓The Questions

1. List all posts which contain no ‘react’s. Your query should return results of the form. (postPermanentID, text). (1 mark)

2. Find the most recently promoted mod (moderator) in the entire database. Assume there are no ties (only one is the most recent). Your query should return results of the form. (modID, username, dateModStatus). (1 mark)

3. List all posts created by user ‘axe’ that have at least 9000 views. Your query should return results of the form. (postPermanentID, viewCount). (1 mark)

4. Find the post which is most commented on (Hint: most ‘originalPostID’ appearances). If there are ties, then you must return all posts with the highest number. Your query should return results of the form. (postPermanentID, totalCommentCount), with one row per post in case of a tie. (2 marks)

5. List the dataURLs for all attachments to posts in channelNames containing ‘dota2’ (e.g., ‘dota2_players’, ‘info20003_better_than_dota2’). Your query should return results of the form. (dataURL, channelID). (2 marks)

6. Find which channel has the highest number of ❤s made to posts within the channel. (Hint: ❤s are simply ‘love’ found in the emoji ENUM). If there are ties, then you must return all results. Your query should return results of the form. (channelName, heartCount), with one row per channel in case of a tie. (2 marks)

7. Find the names of controversial users: defined as users who have < 60 reputation, have at least 1 moderatorreport on one of their posts, and at least 3 ‘love’ react’s given to their posts in total. Your query should return results of the form. (userID, reputation, totalModeratorReports, totalLoveReacts). (2 marks)

8. List the top 3 channels with the largest number of posts with attachments identified with virus(es). Also return the total count of such attachments for each channel. Your query should return results of the form. (channelID, channelName, totalVirusInfectedAttachments). If there are ties in the top 3 positions, you must return all ties. For example, let’s say the database contains seven channels and the ‘total number of virus-afflicted posts’ for each channel are (5, 4, 4, 3, 3, 2, 1). The top 3 counts are 5, 4 and 3 so you need to return the top 5 rows, which are the ones having attachment counts of (5, 4, 4, 3, 3). (3 marks)

9. We’ll use the term ‘repeater’ to describe a user who has had posts in more than one channel reported. Find moderators, and determine how many ‘disciplinary actions’ (as per the disciplinaryAction flag) they’ve given to ‘repeater’ users. Your query should return results of the form. (modID, numberOfDisciplinariesToRepeaters). (3 marks)

10. Find users who have not posted (or commented on any post) before 01/04/2024 in the channel ranked_grind, but have posted at least one COMMENT (a post which is a reply to another post) in dota2_memes on or after 01/04/2024. Your query should return results of the form. (userID) for all such users. (3 marks)

⚠ SQL Response Formatting Requirements

Please pay special attention to the penalties listed [⚠].

To help us mark your assignment queries as quickly/accurately as possible, please ensure that:

• Your query returns the projected attributes in the same order as given in the question and does not include additional columns.

o E.g., if the question asks, ‘return as (userId, name)’, please write SELECT userId, name …

o ⚠ DO NOT return attributes in the WRONG order, e.g., SELECT name, userId…

o You can name the columns using `AS` however you’d like, only the order matters. E.g., this is fine: SELECT userId, name AS fullName

• Please do NOT use “databaseName.tableName” format.

o E.g., please write “SELECT userId FROM users…”

o ⚠ DO NOT provide the database name, e.g. SELECT userId FROM coltonc.users ….

• Ensure that you are using single quotes ( ' ) for strings (e.g. …WHERE name = 'bob'…)and double quotes ( " ) only for table names (e.g. SELECT name FROM "some table name with spaces"…).

o ⚠ Do NOT use double quotes for strings: …WHERE name = "bob"….

o ⚠ Do NOT use Microsoft Word ‘smart quotes’ (the fancy ones as you see in “this” ‘example’).

• Comments are optional, but we recommend writing them for complex queries.

• ⚠Do NOT delete the special comment markers in the SQL template file. These include: -- BEGIN QX, -- END QX, and -- END OF ASSIGNMENT (where X is the question number). They help us mark your submission so tampering with them will hinder our marking and will attract penalties         

内容概要:本文针对传统三电平并网逆变器在谐波抑制、电网不平衡适应性及动态响应方面的不足,提出一种基于有源中点箝位(ANPC)三电平拓扑的高性能并网控制策略。该策略深度融合双极性倍频脉宽调制(DPWMA)、正负序分离锁相技术与电网电压前馈控制,构建了“精准同步—扰动补偿—优质调制”三位一体的一体化控制体系。依托ANPC拓扑在开关损耗均衡、中点电位稳定和低谐波输出方面的硬件优势,结合DPWMA调制提升等效开关频率、正负序分离实现不平衡电网下的精确锁相、前馈控制克服闭环滞后等先进控制手段,显著改善了系统的稳态电能质量、动态响应速度与复杂工况适应能力。通过多工况仿真验证,该复合策略在稳态运行时可大幅降低总谐波畸变率,在电网不平衡与动态扰动工况下仍能维持并网电流对称、功率平稳及快速恢复能力,展现出优异的综合性能与工程应用潜力。; 适合人群:具备电力电子与电力系统基础知识,从事新能源并网、逆变器控制、微电网或相关领域研究的研发人员及研究生。; 使用场景及目标:① 提升高功率并网逆变器的电能质量与运行稳定性;② 解决电网电压不平衡、畸变等复杂工况下的并网难题;③ 优化动态响应性能,提升系统抗扰能力;④ 为ANPC拓扑与先进控制策略的工程化应用提供技术参考。; 阅读建议:建议结合仿真模型深入理解DPWMA调制、正负序分离锁相与前馈控制的实现细节,重点关注多工况下的性能对比分析,以掌握复合控制策略的设计逻辑与优化效果。
内容概要:本文针对海岛微电网中可再生能源出力波动与负荷需求不确定性的问题,提出了一种基于“空调-电动汽车”联合虚拟储能的优化调度方法。通过挖掘空调负荷的热舒适弹性与电动汽车充电的时空灵活性,构建联合虚拟储能模型,将其等效为可调度的储能资源参与系统能量平衡。研究建立了考虑多时间尺度协调、系统运行约束及经济性目标的优化调度模型,并采用Matlab进行仿真求解,实现了对海岛孤立微电网的日前-实时双层协同调度。该方法有效提升了系统对风光等分布式能源的消纳能力,降低了对传统物理储能的依赖,增强了微电网运行的经济性、稳定性与能源自给能力。; 适合人群:具备一定电力系统分析、优化算法理论及Matlab编程基础的科研人员或研究生,尤其适用于从事微电网能量管理、虚拟储能技术、需求侧响应、电动汽车与电网互动(V2G)等领域研究的专业技术人员。; 使用场景及目标:①应用于海岛、偏远地区等孤立电网环境,提升供电可靠性与能源利用效率;②为高比例可再生能源接入的微电网提供灵活调节资源,缓解功率波动;③探索空调与电动汽车等柔性负荷协同参与电网调度的潜力,推动需求侧资源由“被动消纳”向“主动支撑”转变;④实现微电网多时间尺度下的经济优化运行。; 阅读建议:建议结合文中所构建的数学模型与Matlab代码实现部分同步学习,重点理解虚拟储能的建模思路、目标函数的设计逻辑以及约束条件的处理方法,并可通过调整可再生能源出力、负荷水平及电动汽车渗透率等参数进行多场景仿真,深入掌握联合虚拟储能对系统调度性能的影响机制。
内容概要:本文详细介绍了一种基于粒子群算法(PSO)优化BP神经网络的PID控制算法,并提供了完整的Matlab代码实现。该方法结合了PSO算法强大的全局寻优能力与BP神经网络的非线性映射和自学习特性,通过PSO优化BP网络的初始权值和阈值,有效克服了传统BP算法易陷入局部极小、收敛速度慢的问题,从而提升了神经网络在PID控制器参数整定中的精度与鲁棒性。优化后的神经网络用于在线实时调整PID控制器的比例、积分和微分参数,实现了对复杂非线性、时变系统的高性能自适应控制。文档还指出,该技术可拓展应用于如离网风光互补制氢合成氨系统的容量配置与调度优化等实际工程场景,展现了其在智能控制与能源系统优化领域的广阔应用前景。; 适合人群:具备一定Matlab编程基础和控制理论知识,从事自动化、控制工程、电气工程、能源系统优化及相关领域的研究生、科研人员及工程技术人员。; 使用场景及目标:①解决传统PID控制器在处理非线性、强耦合及时变系统时参数整定困难、控制性能不佳的问题;②学习并掌握智能优化算法(PSO)与人工神经网络(BPNN)在先进控制策略中的交叉融合应用方法;③通过Matlab仿真平台,实践基于神经网络的自适应PID控制系统的建模、仿真与性能分析,深入理解智能控制算法的设计流程与实现细节; 阅读建议:此资源侧重于算法的工程化实现与仿真验证,建议读者在Matlab环境中动手复现代码,重点关注PSO优化BP网络的实现逻辑、神经网络在线整定PID参数的控制结构设计以及不同工况下的系统响应曲线分析,通过对比实验深刻体会智能优化算法对控制系统性能的提升效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值