INFO 1103 Homework Project 2

Similar documents
FIT 100 More Microsoft Access and Relational Databases Creating Views with SQL

Carnegie Mellon University Department of Computer Science /615 - Database Applications C. Faloutsos & A. Pavlo, Spring 2014.

Unit Assessment Guide

Database Design. A Bottom-Up Approach

CS 200. Lecture 06. Database Introduction. Database Introduction. CS 200 Winter 2018

Module 9: Managing Schema Objects

CS 200. Lecture 05. Database Introduction. Database Introduction. CS 200 Spring Monday, June 3, 2013

Database Systems. phpmyadmin Tutorial

T-SQL Training: T-SQL for SQL Server for Developers

CS Reading Packet: "Database design, part 1"

CS 2316 Homework 9b GT Thrift Shop Due: Wednesday, April 20 th, before 11:55 PM Out of 100 points. Premise

Data about data is database Select correct option: True False Partially True None of the Above

CS 200. Lecture 09 FileMaker vs SQL & Reports. FileMaker vs SQL + Reports. CS 200 Spring 2018

COSC Assignment 2

In This Lecture. Yet More SQL SELECT ORDER BY. SQL SELECT Overview. ORDER BY Example. ORDER BY Example. Yet more SQL

CS Homework 4 p. 1. CS Homework 4

CS Final Exam Review Suggestions

Advanced SQL. Chapter 8 finally!

MET CS 669 Database Design and Implementation for Business Term Project: Online DVD Rental Business

PART 1 - E-R Modelling - THIS PART DOES NOT USE SQL*Plus or ORACLE AT ALL!

Chapter 5. Database Processing

MASTER-DETAIL FORMS. In this Chapter, you will learn about: Master-Detail Forms Page 108

CS Homework 4 p. 1. CS Homework 4

EE221 Databases Practicals Manual

CS 4320/5320 Homework 2

Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

Exercise Sheet 8: SQL 1 (until Thursday, ) (45 Points)

BIS1523 Homework Assignments 2.1

CS Homework 4 p. 1. CS Homework 4

This handbook contains directions on using tools and resources in WebAccess at CSM.

Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

ER Modeling Data Modeling and the Entity-Relationship (ER) Diagram Pg 1

CS Homework 5 p. 1. CS Homework 5

Want the *GUIDED* tour?

CS313D: ADVANCED PROGRAMMING LANGUAGE

1.204 Computer Algorithms in Systems Engineering Spring 2010 Problem Set 2: Municipal Database Due: 12 noon, Wednesday, February 24, 2010

CS352 - DATABASE SYSTEMS. To give you experience with developing a database to model a real domain

WHAT IS A DATABASE? There are at least six commonly known database types: flat, hierarchical, network, relational, dimensional, and object.

HKALE 2012 ASL Computer Applications Paper 2 Disscussion forum system

[18 marks] Consider the following schema for tracking customers ratings of books for a bookstore website.

CS 3030 Scripting Languages Syllabus

Writing Queries Using Microsoft SQL Server 2008 Transact- SQL

Querying Data with Transact SQL

CS44800 Practice Project SQL Spring 2019

CS Homework 3. Deadline: How to submit: Purpose: Additional notes: Problem 1. CS Homework 3 p :59 pm on Thursday, October 3, 2013

Lesson 13 Transcript: User-Defined Functions

CISC 7610 Lecture 4 Approaches to multimedia databases

Effective Keyword Search in Relational Databases for Lyrics

The Relational Model. Week 2

Implementing Table Operations Using Structured Query Language (SQL) Using Multiple Operations. SQL: Structured Query Language

G64DBS Database Systems. Lecture 7 SQL SELECT. The Data Dictionary. Data Dictionaries. Different Sections of SQL (DDL) Different Sections of SQL (DCL)

Writing Queries Using Microsoft SQL Server 2008 Transact-SQL. Overview

CS157a Fall 2018 Sec3 Home Page/Syllabus

MySQL for Beginners Ed 3

Transaction Isolation Level in ODI

CS50 Quiz Review. November 13, 2017

CSCI 403: Databases 13 - Functional Dependencies and Normalization

Homework 4: Query Processing, Query Optimization (due March 21 st, 2016, 4:00pm, in class hard-copy please)

CS Homework 10

CS Homework 5 p. 1. CS Homework 5

Spring CS Homework 2 p. 1. CS Homework 2. To practice with PL/SQL stored procedures and functions, and possibly exception handling.

Transactions Lab I. Tom Kelliher, CS 317

INFSCI 2710 Database Management Solution to Final Exam

CHAPTER 2: DATA MODELS

Higher National Unit specification: general information. Relational Database Management Systems

Database Management

COURSE OUTLINE. IST 253 Database Concept 3 Course Number Course Title Credits

Math 2280: Introduction to Differential Equations- Syllabus

CSC 4710 / CSC 6710 Database Systems. Rao Casturi

Anchor Modeling A Technique for Information under Evolution

Entity Attribute STUDENT TABLE tuples single domain

Importing source database objects from a database

TDA357/DIT620 Databases lab assignment

RELATIONAL ALGEBRA II. CS121: Relational Databases Fall 2017 Lecture 3

CS Homework 7 p. 1. CS Homework 7. Problem 1 - START THIS A.S.A.P. (in case there are PROBLEMS...)

SQL - Subqueries and. Schema. Chapter 3.4 V4.0. Napier University

SQL Simple Queries. Chapter 3.1 V3.01. Napier University

CSCI-UA: Database Design & Web Implementation. Professor Evan Sandhaus

Database Systems, CSCI Exam #2 Thursday November 4, 2010 at 2 pm

Informatics 1: Data & Analysis

CSC 380/530 Advanced Database Take-Home Midterm Exam (document version 1.0) SQL and PL/SQL

ITEC 101 LAB 9 USING A DATABASE: Tables and Queries

CS 161 Computer Security

Database Design - Section 11. Instructor Guide

Adding content to your Blackboard 9.1 class

MSQuery-DM ad hoc reporting from SQL Server 9/25/2013

CS352 - DATABASE SYSTEMS

modern database systems lecture 5 : top-k retrieval

Copyright 2017 by Kevin de Wit

CHAPTER4 CONSTRAINTS

Learning Alliance Corporation, Inc. For more info: go to

CS 2316 Individual Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 18th, before 11:55 PM Out of 100 points

CSE 341, Autumn 2005, Assignment 3 ML - MiniML Interpreter

3. Getting data out: database queries. Querying

Schema And Draw The Dependency Diagram

Tutorial 8: Practice Exam Questions

DATABASE MANAGEMENT SYSTEM

CIS Homework 3

MovieRec - CS 410 Project Report

CIS 207 Oracle - Database Programming and SQL HOMEWORK: # 13

Transcription:

INFO 1103 Homework Project 2 February 15, 2019 Due March 13, 2019, at the end of the lecture period. 1 Introduction In this project, you will design and create the appropriate tables for a version of the system used in Homework 1. Although your ERD solution for Homework 1 might be as good or better than the one in the diagram below, please use the provided one. insert some data into each table. write SQL queries against this data. Remember, this is to be individual work, unlike the labs. 1

Figure 1: Starting ERD 2 Details Details follow about table creation, data insertion and the required queries. 2.1 Table Creation Refer to Figure 1, which is a subset of the ERD from Project 1. (The names of attributes probably don t meet the guidelines from the textbook.) In the given design, Song Recording is an associative entity that replaces a many-to-many relationship between Album and Song. Its multivalued attribute time played gives the times (date and time of day) when the song was played by the station. Both original lyrics and modified lyrics are optional. There are two sets of lyrics because sometimes a recording artist will sing something slightly changed from the original lyrics. Don t forget to enforce that only certain rating score values are allowed. Since I have not provided metadata definitions for entities, relationships and attributes, you will have to rely on your own best guesses based on attribute 2

names as to the appropriate types. Use some form of whole numbers for unique identifiers. Ask me questions if you wish. Create a.sql script in the Oracle tool that contains the commands necessary to build the tables. Include all appropriate constraints for domain values, foreign keys and primary keys. Follow the steps for generating tables from ER models (in Chapter 4). 2.2 Data Creation Continue your.sql script to contain the necessary SQL INSERT commands to add several rows to each table. Some of the rows will be of your own choosing, but you need to make sure that the rows added also include the following: 1. at least 4 users. The first user has user id = 1 and has 2 past payments recorded. One of the other users has user id=2 and has 1 past payment recorded. 2. at least 6 songs. One song (with song id=1) has been recorded 3 times and one song (with song id = 2) has not been recorded at all. The rest have been recorded once each. We have original lyrics for one song that was then recorded with different lyrics. 3. at least 4 albums. None of them have the cover photo (since we don t want to get into BLOBs with images). 4. at least 8 comments from user id=1 and at least 2 comments from user id=2. At least 2 song recordings have been commented on. For one song recording, user id=1 commented, user id=2 did a comment in response, and then user id=1 commented in response to the response. At least one user has no comments. 5. Three users upvoted one comment and downvoted another comment. One of comments was upvoted by the comment s author, and (strangely) another comment was downvoted by its author. 6. at least 4 ratings. Two users are responsible for all the ratings. In at least one case, a user has rated a recording but not commented on it. In at least one case, a user has commented on a recording but not rated it. And in at least one case, a user has both commented on and rated a song recording. The song with song id=1 has had all its recordings rated by user id=1, who loved one of the recordings and hated the other two recordings. 7. Attempt to insert a rating whose score is outside of the allowed range. The attempt should fail. 8. Two recordings have been played 3 times each and another has been played 2 times. Use non-null dates when recording this information. 3

2.3 Queries Continue your.sql script with some SELECT and CREATE VIEW commands. Some of the queries can be answered from a single table, although many of them require joining tables. Don t take advantage of the fact that you know what is in each of your tables. The grader should be free to add additional rows into your tables, if he wishes. Give SQL statements for the following. The first 11 are worth 2 points each and the remaining 6 are worth 3 points each. 1. Determine the number of users. 2. For each song, give its title and id, as well as the album name and artist of each recording of it. Sort the result by song id. 3. For each song, give its title and id, as well as the album name and artist and average rating of each recording of it. 4. For each user, determine the total value of the past payments they have made. 5. For each different song title, give the number of distinct artists who have recorded it. If two different songs have the same title, their results should be combined. 6. For each album (by id and name), determine the total number of comments about recordings on it. 7. For song id 1 and user id=1, list the album names where they rated at a recording of the song, and show the rating they gave. 8. For each album (by id and name), give the number of recordings on it and the average rating for the recordings on it. Your result should be sorted by album and ranking. 9. Give the name and id of each user and also the number of comments made by the user. Make sure that users who have never made a comment are listed as having 0 comments. 10. List the songs, by title, where some recording has different (non-null) lyrics from the song s original lyrics. 11. For each recording (give album name and song title) that has been played at least 2 times, give the number of times it has been played and the date when it was most recently played. 12. Show the comments (id and words) and their authors names when the person who wrote the comment also voted on the comment. Show the direction of each such vote. 4

13. (a) Show the comments (ids and words) that are responses to original (non-response) comments. You probably will want to do a self join. (b) Repeat, except you want comments that are responses to responses to original comments. 14. Show the recordings (by album name and song title) that nobody has rated. The minus or except operator is likely to be helpful. 15. Create (and show) two views (a) One gives, for each user id, the highest rating the user has given. (b) One gives, for each rating given, the user id, song title and album name that goes with it. 16. Using the views from the previous question, provide a list, sorted by user name, showing each user s name and the recordings (by song title and album name) that have received that user s top rating (also show the rating received). Users who have submitted no ratings should not be listed. 17. For each user, show their most highly rated album (taking the average of the ratings they have given recordings on the album). In the event of ties, you may either list several albums or just choose one of them. Users who have never rated anything should not be shown. The queries are generally listed in order of my perception of their difficulty. My perception might not match your reality; if one query is stumping you, go on and try the next. However, your script should have the queries in the given order. Please use SQL comments (eg -- query 3) in the script to indicate which query you are giving. 3 Grading Submit your.sql script that creates the tables, populates them, and then answers the queries. It should be possible for whoever grades the assignment to run your script in Oracle SQL Developer and get results, without errors. Submit this on paper and in D2L. The table creations are worth 40%, the insert commands are worth 20%, and the queries (and view creation) are worth 40%. Also, submit (paper and D2L) the transcript of what happens if you play the script (i.e., the contents of the output window in Oracle SQL Developer). 5