[SOLVED] 7CCSMDDW- MSc_Database_CW1-main

30.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

5/5 - (1 vote)

Database Implementation and Manipulation Using SQL

 

 

Schema Definition. Based on the design and requirements above, write the required SQL DDL (Data Definition Language) statements (i.e. CREATE TABLE) to create the corresponding tables. Ensure that:

    • table and attribute names do not conflict with SQL reserved words
    • attribute data types are core SQL data types
    • your tables implement entity, referential and domain constraints as needed
    • every table has a primary key specified as it corresponds to your relational model
    • all foreign keys are properly declared
  • Populate Database with data. Time to get creative! Populate your database with some data that you will come up with on your own. Since you only require a small test sample of data, use SQL INSERT statements to populate your database. More precisely:
    • Create at least two departments.
    • Create at least 3 academics per each department.
    • Create at least 10 students. The start date should be earlier than today. There should be at least one student who started last year.
    • Include at least 1 supervisor per student.
    • Create at least 2 projects per each academic. The end date should be greater than the start date. There should be at least one finished project (with an end date in the past) and one ongoing project (with an end date in the future).
    • Include at least 4 collaboratesIn per academic.

Write your INSERT statements in the provided template file: insert.sql

  • Creating views. Write SQL statements to:
    • Produce a view that returns ongoing projects (i.e., projects that will end in the future) and rejects any attempt to insert or update finished projects.

Write all of these SQL statements in the above order in the provided template file: view.sql

  • Querying the Data. Write the SELECT statements that to obtain the following queries:
    • 1. Research Involvement. The university would like to know which academics are currently involved in research, either as supervisors of PhDs, as coordinators of an ongoing project or working in an ongoing project. List the name and surname of these academics.
    • 2. Male Supervision Report. The university would like to know how many PhD male students are being first supervised by each supervisor. Include also the academics that are not supervising any male PhD students.
    • 3. Number 1 and 2 by Research Income. The university would like to personally email its top 2 academics by their research income (i.e., the total budget on the projects coordinated by them). Write a SELECT query that lists the academic’s name, surname and email. Sort the academics by their research income, showing the top-income academic first.
    • 4. Most Overloaded Academic. List the information about the academic who is currently collaborating more hours on ongoing research projects. Note there may be more than one most overloaded academic.

Write all of these SELECT statements in the above order in the provided template file: select.sql

  • Updating the Data. Write the UPDATE (and possibly other) statements to perform the following operations:
    • It is possible that some PhD students have a second supervisor but not a first supervisor. Create queries (it is possible that you may need to use something more than just update statements) to avoid this problem by making that the second supervisor becomes the first supervisor when there is no first supervisor.

Write these statements in the provided template file: update.sql

  • Removing Data from the Database. Write the DELETE statements to perform the following operation:
    • PhD students without a second supervisor have decided to leave the university. Write the DELETE statement(s) that removes these students from the database. To avoid any future embarrassment in case of a data leak, make sure you remove all trace of these students from the database.

Write all of these DELETE statements in the provided template file: delete.sql.

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.