首页 > 数据库 >158.337 Queries (SQL/LINQ), Triggers

158.337 Queries (SQL/LINQ), Triggers

时间:2024-09-20 12:14:56浏览次数:10  
标签:code Triggers work LINQ should will SQL query your

158.337 Group Project Instructions: Part B

(Course mark - 17.5%)

You will continue to work in groups* for this assignment. You do not need to register again but in case you change your group membership please let us know via emailing Indu ([email protected]).  Make   sure  you  formally  inform. your  Assignment  Part  A partner(s) as well. You will lose significant marks if you do not work in a group without a very strong reason and permission. You can use the group forum for this should you need to but do this early on; in fact, sort this first. Any other submission irregularities will also have a penalty.

Use the following instructions to guide you in the Four Sections (Section A – Section D) of the project. You should turn the work in for grading by the due date (Tuesday, 15th Oct 4.00 pm).

Notes:

•    *Working in a group does not mean you completely split the work or probably work only on one section. You should all work on each section and then compare your work i.e. have discussions around any differences (e.g., different results, style. of coding, getting stuck, etc.). Subsequently you collate put your best work in the report. We suggest you start working on assignment in parallel (this will also prepare you for the coding test which is required to be done individually).

•   Make sure you have altered the password of your (Group) Oracle a/c and keep it safe within your group. You do not want other people accessing your account and code. We have seen this in past that occasionally students have been able to access other group accounts,  if  the  default  passwords  have  not  been   changed.  Remember  it  is  your responsibility to protect your work.

•   Do not post any  assignment queries on the  Stream’s  discussion  forum. Everyone is expected to work within their group and such posts either give away the answer or may pose some confusion to other groups who may be writing scripts differently.

PART B

Queries (SQL/LINQ), Triggers, Procedures, Function, Cursor (PL SQL) & MongoDB (NoSQL)

Download  following  two  files  provided  in  a  compressed  folder  (PartB.zip)  under  the Assignment heading from the Stream site:

University database file (UniversityDatabase.sql) - for Sections A, B and C.

The file provides code to create the required database in your account. Seven tables created are – LOCATION, FACULTY, STUDENT, TERM, COURSE, COURSE_SECTION, and ENROLLMENT.

Collection file (NoSQL.txt) - for Section D.

Use script. files (use some text editor e.g., Notepad++) for writing your solution code. Name your files appropriately (e.g., SectionA.sql). Include query number (e.g., a) along with the given query question (e.g., Write a query that will list...) as part of the comment before writing the solution code (SQL / PL/SQL / LINQ) in these files. Annotate your code with suitable comments wherever necessary.

Use a Word file for your project report (this can be later converted into a pdf should you prefer to submit a pdf report). As mainly the report will be used for grading so you will need to transfer your final working code from the script. files to this report as well. Here you also need to include the outputs of your code (e.g., query results, etc.). The outputs presented in the report should be well formatted (properly aligned, appropriate column names, etc.) for readability purposes. The script. files will be used wherever required (i.e., we may not the run code for every question but may for the some to confirm that the code works correctly in differently simulated situations).

For PL/SQL (triggers, procedures, etc.) besides the created code, the output produced from running the code 代 写158.337 Queries (SQL/LINQ), Triggers(e.g., procedure successfully created, etc.) you also need to provide the testing examples using some quality test data to prove that procedure/trigger works the way it is intended to work. Once again make it easy for grading by being easy to read but also make it easy should the grader choose to run the code.

All (SQL/LINQ) queries must only be based on the information provided in the assignment question itself (e.g., Write a query that will list...). Do not use a different criterion to arrive at the expected equivalent query result set. Also, do not manipulate the query results by using ROWID, ROWNUM, With Ties, etc. to sort and get the first ranked /last record, etc. Some SQL may require use of subqueries, etc.

Ensure that the query results display the information that is asked including the columns that are necessary to easily evaluate your query results. That does not mean use “*” to display everything – use your judgement and fulfil the query requirements. Your code should work correctly even when the database is modified (e.g., added more records, deleted  some, modified  some values,  etc.). At times, you may  consider making  some  changes to the database itself to see your code works fine for the changed database (works as expected).

Notes:

•   For all exercises asking you to display names, list first name and last name as a single column instead of separate columns.

•   Remember to include all three - the asked question (as comment), the code (SQL /PL SQL /LINQ/ MapReduce) and the output (including any test cases, etc.) in your report. Some questions may have other additional requirements, so meet those as well.

Section A (SQL Queries)            (20 marks)

Note: For each of the questions (a)-(h) in  Section A, write code using a  SINGLE statement ONLY (i.e., you cannot write two separate select statements to arrive at an answer; however, select clause can be used more than once in a statement. There should only be one semi-colon in your code). Use the given criteria only. We will either give full or zero mark for most of the questions in this section so make sure your answer is fully correct.

a.   Write a query that will list the faculty members (along with the building code and room number) who are (located) in the (BUS)iness building.            (1.5 marks)

b.   Write a query that will list students who are enrolled in the courses offered in the Fall term of 2024 or 2025 or Spring term of 2025. Do not display the duplicate student names in the output.          (1.5 marks)

c.   Write a query that will list the total building capacity of various buildings. The rooms with a capacity of less than five must be excluded when generating building’s total capacity. The final query result should list the buildings with a total building capacity of 150 or over. Present this in the increasing order of the total capacity.       (2 mark)

d.   Write a query that will list faculty supervisors and their respective students. Each supervisor’s students should appear in a single row (i.e., list of values instead of separate rows) i.e., if a faculty supervisor supervises more than one student then all the supervised students’ names should appear in a single row (next to each other separated by a delimiter). Present your final output in the order of faculty supervisor's id and include only those results where the number of students against a supervisor is more than 1.

Hint: May have to google for Oracle’s special aggregate function.               (3 mark)

e.   Write a query that will list students enrolled with a total of 12 or more course credit points. List your results in decreasing order of total credit points. Do not assume or hard code the value of the course credits (e.g., 3, 6, etc.).                              (3 mark)

f.   Write a query that lists the courses (with their course names) and the course sections that are offered either on all the three days (M)onday, (W)ednesday and (F)riday or at least four times a week. Also, display the course section days (e.g. MWF), the course section time (e.g. 2 pm), number of the days that the courses are offered (e.g., 5 days). List your results in the increasing order of number of days.

Hint:  The  attribute  c_sec_day  lists  weekdays, where the  first  letter represents  a weekday (e.g. M-Monday,…...,F-Friday; for Thursday R is used). The course section weekdays are listed in the order M(onday) to (F)riday i.e., Monday being the first. (3 marks)

g.   Write a query listing the details of the faculty member(s) who supervise(s) the highest number of students. The result should also display the number of students. The query should also work in situations when more than one supervisor has highest students (e.g., 2 supervisors each having 5 students and 5 being highest number).     (3 marks)

h.   Write a query that will list student(s) enrolled with the highest total course credit points. The result should also display the number of courses that a student is enrolled for, the average credit points, the highest credit points along with the total credit points. (3 would be highest if all enrolled courses are worth 3 otherwise 6 if enrolled with a course worth 6).                                                                                    (3 marks)

Section B (PL SQL)                     (26 marks)

Comprehensive testing examples needed for all PL/SQL (triggers, procedures, cursor, and function). You need to capture and show that you tested your code using good test cases. Include some exception handling as deemed necessary.

a.   Think of a useful business rule or situation (based on the provided database) where it would be appropriate for a trigger to fire. However, do not write trigger to do something that  could  be  done  using  some  database  design  constraints  (e.g.,  simple  referential integrity checking, assign default values to attributes, or simply saying record is being inserted, or an attribute has a null value, etc.). Provide a sensible and useful trigger and do not use the already provided or similar triggers (including tutorial triggers) for this question. Failing to meet these will result in a zero mark. There is also a discretionary mark for the degree of difficulty/relevance, etc. (1 out of the total 7). But do not confirm the trigger quality with staff before submission.

Start first by clearly explaining the context and purpose (what it will do using business language)  of  your  trigger.  Then  provide  the  PL/SQL  code  and  the  results  (using appropriate testing scenarios).

The trigger should be based on the tables already provided. Do not unnecessarily create too many and/or similar tables. Adding one or two tables may be fine – but justification is needed. Altering a table (adding a field) is fine.

Write one trigger (tell the trigger type). Display the successful creation and the results of running the trigger. Ensure that you also display the relevant tables before and after (results of the trigger) the trigger is fired. Remember to provide the purpose of your trigger (as stated in question b below), as this helps us to evaluate your work against the stated trigger requirements.                         (7 marks)

b.   Write a trigger that does not allow more than two 'Full' ranked professors as part of the faculty (For example, trigger should fire if a new (third) Full professor is added or the rank  of  one  of  the   existing  Associate  professors  is  promoted  to  Full).  Provide comprehensive test data and test results to confirm that the trigger works.         (4 marks)

c.   Write a trigger to check that when salary is updated for an existing faculty the raise is not over 5.5%.              (4 marks)

d.   Write a procedure to insert a new faculty record. The procedure should also automatically calculate the faculty salary value. This calculated salary should be  10% less than the average salary of the existing faculty members. Use the rest of the attribute values as input parameters. Execute your procedure to insert at least one faculty record.            (4 marks)

e.   Use a cursor to list course sections for all theMIS courses (along with their courses names and credits). Present the report in the order of course section id and course number. In the end, also display some meaningful summary statistics as part of the outcome.  (4 marks)

f.   Write a function, which can be used to format faculty member’s salary using appropriate format (e.g., $80,000.00). Do not hard code the exact salary datatype (i.e., your function should work even for some minor changes that may be made to the salary data size).

Call this function using a SQL statement for displaying a faculty member’s salary.  (3 marks)

Section C (LINQ Queries)                            (6 marks)

For (a) – (e) below, write queries using LINQ.

a.   List faculty members who earn 80,000 or over.                                        (1 mark)

b.   List courses that have MIS in their course number.                                  (1 mark)

c.   List faculty members and their location details.                                        (1 mark)

d.   Display the total number of rooms in each building.                                (1.5 marks)

e.   Display total number of students supervised by each faculty in the order of faculty last name.                        (1.5 marks)

Section D (NoSQL)                             (8 marks)

Use the code provided in NoSQL.txt to create a collection of 15 rows called dragons.

Now write MapReduce code to generate a report based on:

•   the gender-wise average weight.

Rewrite the above MapReduce code using Aggregation pipeline operators.

Include both the code and the report generated in your assignment report. Place the code in a script. file as well.

Assignment Submission

Organise your final report (print friendly – but soft copy) to include all assignment sections’ work. Make sure the report contents are also in the order of the laid assignment requirements (e.g., section-wise work).

There are three parts to this assignment submission:

•   a report (word/pdf)

•   scripts (code files – one for each section, clearly labelled) and

•   database objects (in your Group’s Oracle account)

You must put your final report and code file(s) into a “single” compressed folder and submit via the Stream Assignment link.

Make sure there are not too many separate/unnecessary duplicated code files (e.g., all section A queries in a single file and not separate files). No duplicate group submissions (ONLY one per group).

Checklist for final report:

Readable format of SQL, PL/SQL, LINQ commands, and Map Reduce code. Remember to include the related outputs along with the code (not separately in an appendix). For some questions, there are additional specific requirements (e.g., purpose of trigger, etc.).

Checklist for submission under your Group Oracle a/c: All objects - database tables, triggers, procedures, etc.

Checklist for Stream submission:

Check your project work and make sure that all the scripts run without any errors. Also, check that appropriate names have been given to all file(s). Upload your report and code on Stream as a single compressed file on the Assignment link.

Notes:

Enter your names, student ids on the project marking sheet (Appendix B). The project report should include this marking sheet (at the front i.e., 1st  page). Make sure to provide the correct Oracle username in your report. Remember to include the script file(s). Make sure your work is well presented (i.e., easy to grade).

Plagiarism and other project guidelines:

Use of any AI tools is NOT Permitted for the course assessments. You can find more information about the Student Academic IntegrityPolicy here. This will lead to a ZERO and may lead to an academic investigation by the Academic lead.

We suggest you keep a record of the intermediate work (work in progress) leading up to    your assignment submission as you may be asked to establish that this is your work and is done over a period of time.

ZERO mark will be given to ALL the collaborating parties (no discussion on who did the original work and who copied). Any partial copying will also be awarded a straight

ZERO.

Make   sure   all   your   work   is   complete   before   you   submit.   Graders   will   not   be searching/chasing you for any not easily traceable/missing assignment component(s).

Not adhering to any of the assignment requirements, may also be given a straight ZERO.

We expect each group member to genuinely and independently work on all the sections. Any reported non-contributors within  a group may be given a ZERO.

Note: Turnaround time for assignment may be slightly over the usual three weeks.

 

标签:code,Triggers,work,LINQ,should,will,SQL,query,your
From: https://www.cnblogs.com/WX-codinghelp/p/18422243

相关文章

  • 【实战篇】MySQL是怎么保证高可用的?
    背景在一个主备关系中,每个备库接收主库的binlog并执行。正常情况下,只要主库执行更新生成的所有binlog,都可以传到备库并被正确地执行,备库就能达到跟主库一致的状态,这就是最终一致性。但是,MySQL要提供高可用能力,只有最终一致性是不够的。主备切换可能是一个主动运维动......
  • 【实战篇】MySQL是怎么保证主备一致的?
    MySQL主备的基本原理如图1所示就是基本的主备切换流程。在状态1中,客户端的读写都直接访问节点A,而节点B是A的备库,只是将A的更新都同步过来,到本地执行。这样可以保持节点B和A的数据是相同的。当需要切换的时候,就切成状态2。这时候客户端读写访问的都是节......
  • 数据库数据恢复—SQL Server数据库附加数据库出现823错误,附加失败的数据恢复案例
    SQLServer数据库故障:SQLServer附加数据库出现错误823,附加数据库失败。数据库没有备份,无法通过备份恢复数据库。SQLServer数据库出现823错误的可能原因有:数据库物理页面损坏、数据库物理页面校验值损坏导致无法识别该页面、断电或者文件系统问题导致页面丢失。SQLServer数据......
  • Liunx安装mysql8.0.39版本以及如何远程连接Navicat保姆级教学
    前言:对于MySQL数据库的安装,我们将要使用安装方式rpm进行安装通过百度网盘分享的文件:mysql-8.0.39-1.el7.x86_64.rpm-bundl...链接:https://pan.baidu.com/s/1uAOqAeH03eU7t8T1_ekXXA?pwd=obce 提取码:obce其他版本链接:MySQL::DownloadMySQLCommunityServer1:检测当前......
  • MySQL在大数据场景应用
    MySQL是一个功能强大的关系型数据库管理系统,虽然它最初设计用于处理中小规模的数据,但随着技术的发展和优化,MySQL也被应用于一些大数据场景。MySQL在大数据场景下的应用:1.数据仓库MySQL可以作为数据仓库使用,存储和管理大量的业务数据。通过合理设计表结构、使用分区表和索引......
  • MYSQL解说
    MySQL是一个流行的开源关系型数据库管理系统(RDBMS),广泛用于网站和应用程序的后端数据存储。MySQL的基础知识:1.数据库和表数据库(Database):存储数据的逻辑容器。表(Table):数据库中的数据结构,由行(记录)和列(字段)组成。2.SQL语言SQL(StructuredQueryLanguage):用于管理和操作关系型......
  • SQLPlus执行成功但数据没有更新的原因及解决办法
    在使用sqlplus执行SQL文件时,如果执行成功但数据没有更新,可能有以下几个原因导致:1.没有提交事务在Oracle数据库中,执行UPDATE,INSERT,DELETE等操作后,默认不会自动提交事务。如果没有显式地提交事务,修改的数据将不会永久保存。解决办法:确保在SQL文件或命令行......
  • 06-VIP-深入理解Mysql事务隔离级别与锁机制
    概述我们的数据库一般都会并发执行多个事务,多个事务可能会并发的对相同的一批数据进行增删改查操作,可能就会导致我们说的脏写、脏读、不可重复读、幻读这些问题。这些问题的本质都是数据库的多事务并发问题,为了解决多事务并发问题,数据库设计了事务隔离机制、锁机制、MVCC多版本并......
  • .net使用Freesql连接瀚高数据库
    https://www.cnblogs.com/Lynnyin/p/18375455 默认情况下Freesql可以使用PostgreSQL的连接方式连接,如果是md5加密的varisdatabase=MyRedis.GetStringKey("DataBaseType");varsqlConnStr="Server=192.168.1.111;Port=5866;UserId=root;Password=123456;Database......
  • 如何解决"Can't connect to MySQL server on 'hostname' (10061)"问题
    当遇到"Can'tconnecttoMySQLserveron'hostname'(10061)"这类错误时,通常意味着应用程序无法连接到MySQL数据库服务器。错误代码10061通常表示连接拒绝,可能是因为服务器没有响应或者不允许来自该客户端的连接。以下是解决此类问题的一些步骤:解决方法:检查数据库服务......