USING SQL FOR QUERYING A RELATIONAL DATABASE

USING SQL FOR QUERYING A RELATIONAL DATABASE

The primary theme of the paper is USING SQL FOR QUERYING A RELATIONAL DATABASE in which you are required to emphasize its aspects in detail. The cost of the paper starts from $109 and it has been purchased and rated 4.9 points on the scale of 5 points by the students. To gain deeper insights into the paper and achieve fresh information, kindly contact our support.

1   Introduction

This is an individual assignment, to be submitted electronically using the Blackboard facility. A

submission link will be enabled on blackboard closer to the submission date.

 

The objective of this assignment is to reinforce what you have learned in the lectures and tute/ lab sessions. Specifically, it covers the advanced concepts in the relational database model, using SQL for querying a relational database and analyse different database models for different applications.

 

1.1  Plagiarism

All code or other material that is not original must be fully credited. That is, any material that is copied or derived from another source must be clearly identified as such and the original author must be identified. Sometimes students assist each other with an assignment, but end up working together too closely, so that the students` separate solutions have significant parts in common; unless the solutions were developed independently, they are regarded as plagiarised.

 

Plagiarism is a very serious offence. Any submissions determined to be a result of plagiarism will be deemed as an academic misconduct and harsh penalties apply. It is also an offence for students to allow their work to be plagiarised by another student. You should familiarize yourself with the university website for Academic Integrity Policy, Procedures and Guidelines. All work is to be done individually and plagiarism of any form will be dealt with according to the RMIT plagiarism policy.

 

1.2  What to Submit, When, and How

 

1.2.2 What

You should submit one PDF document with all answers together. You can use Oracle SQL Developer (or SQLiteStudio) to work on your assignment. You may use Word or any other word processor to compile your submission. At the end, convert it into PDF format. Do not submit Word files. if that option is not available on your system there are free pdf converters online you can utilise.

 

1.2.3 How

You are required to submit your solution electronically using the Blackboard facility. A submission link will be enabled on blackboard closer to the submission date.

 

1.2.4 Penalties for late submissions

Late submissions of assignments will be penalised as follows. For 1 to 5 days late, a penalty of

10% (i.e. 10% out of total marks, not 10% out of your marks) per day. For assignments more than

 

 

1.2.5 Special Consideration

If unexpected circumstances affect your ability to complete the assignment you can apply for special consideration. If you seek a short extension, you can directly contact the lecturer. For longer extensions, you must follow instructions provided at

 

1.3  Preparation Tasks

Part A of this assignment is based on the same ER model used in Assignment 1 Part A section 2). Part B of this assignment is based on the same relational database schema used in Assignment 1. Review your answers for the corresponding question in Assignment 1 before attempting this assignment.

 

2   Part A: Relational Database Design (30 Marks)

Consider the following E-R diagram, which models an online bookstore. As a part of the Assignment 1 activities, we have mapped entities and relationships in this E-R model into a relational database schema.

 

  1. 1. For each of these relations, write down all non-trivial functional dependencies. If there are no functional dependencies among attributes, you must state
  2. 2. Write down the highest normal form each of these relations are in. For each of these relations, state the reasons why it doesn’t meet the next normal form requirements. This is not required if the relation is in 3NF.
  3. 3. If they are not in 3NF, decompose them into 3NF relations.
  4. 4. Where possible, combine the relations resulting from Part 3.

 

  1. 5. Write down the final relational database schema.

 

ImportantNo marks are awarded to the final schema in Part 5 if you do not show the workings of decompositions (in Part 3) and combining relations (in Part 4). Indicate the primary key (underlined) and foreign key(s) (with an asterisk*) in each relation.

 

3   Part B: SQL (40 Marks)

LibraryDB is a database system that keeps track of information concerning the books and their circulation in an imaginary library.

 

Disclaimer: The data that populates the database are artificially constructed and by no means correspond to actual real-world data.

 

The schema for the LibraryDB database is given below.

 

Description of the schema

  • person -- keeps track of the people who borrow books from the library. The attributes contain personal and contact information.
  • author -- keeps track of personal information about authors.
  • publisher -- keeps track of the publisher information. To make simple, most of the attributes have been truncated in the sample database.
  • subject -- this relation keeps information about the subjects on which the library collection have books (such as Mathematics, Database, etc)
  • book -- contains information about the books that are available in the library. Every book can have one or more physical copies in the collection. Each book can have one or more authors and it is published by one or more publishers.
  • book_copy -- keeps track of the physical copies of the books in the library collection.
  • borrow -- keeps track of the check-ins and check-outs of the books. Every transaction is done by one person, however may involve with one or more book copies. If there is no return date, it means the book has been checked out but not returned.
  • written_by -- associates books with authors. A book may be associated with several authors and an author may be associated with several books. There is also an attribute

`role` that specifies the role of the author for the book (author/ editor/ translator/ etc).

  • published_by -- associates publishers with books. There is an attribute `role` here too.
  • borrow_copy -- associates physical copies of books with a transaction. Members are allowed to borrow several books in a single transaction.

 

A conceptual data model (shown as an entity-relationship diagram) which represents these data is given below.

 

You can access a sample database instance of this library database system using Oracle SQL Developer (either on myDesktop or lab machines) or sqlplus on core teaching servers (titan, jupiter or saturn.) Please follow the instructions provided on the Blackboard to access the sample database.

 

 

If you wish to do this part of the assignment from home, you can install SQLite (with SQLite Studio). The instructions for installing, configuring and using SQLite Studio is provided in the Databases and Tools section of the Blackboard. Also included is the pre-built Library database in SQLite format (Library.db) at the same location.

 

Write SQL queries for the following tasks.

  1. 1. Display the titles of books that never borrowed. a.   Write your query using OUTER JOINs.
  2. b. Write the query again without using OUTER JOINs.
  3. 2. With which publisher(s) the author Alfred Aho published his book(s)? Display publishers` full names.
  4. 3. Who are the authors published the books with MC GRAW-HILL publisher? Display the firstname and lastname of the authors.
  5. 4. Display the first name and lastname of authors who wrote more than 3 books. Along with each name, display the number of books as well.
  6. 5. Display the title of the book which has most physical copies. If there are more than one

book with the largest number of copies, show them all. Your query should show the number of copies along with the title.

 

Provide detailed answers to the following questions.

  1. 6. According to this database schema, it is assumed that all booked borrowed in one transaction are to be returned together. However, this is an unreasonable assumption and quite contrary to the common practice across all forms of libraries. You can return books (borrowed together) separately.

 

Provide the required changes to the database schema to accommodate this requirement. Your answer should include a portion of the ER model where the changes are applied and the updated relational database schema. If required, you may add new relations and attributes and also new foreign keys.

 

  1. 7. This database schema cannot keep information on holding of books. Extend this schema to accommodate this requirement.

Your answer should include a portion of the ER model where the changes are applied and

the updated relational database schema. If required, you may add new relations and attributes and also new foreign keys.

 

  1. 8. The library allows customers to extend their loans before the due date.
  2. a. Can this database schema handle loan extensions? If so, how are they handled? If not, what changes required to the database schema?
  3. b. If there is an additional condition that a customer can extend their loan only two

times, can this database schema handle loan extensions? If so, how are they handled? If not, what changes required to the database schema?

Your answers should include a portion of the ER model where the changes are applied and

the updated relational database schema. If required, you may add new relations and attributes and also new foreign keys.

 

4   Part C: Research Question (30 Marks)

 

Let`s assume that a decision was made to re-write the Facebook application from scratch, mainly due to recent performance issues it is dealing with. You are assigned the task of producing an analysis of backend database server options that can cater the volume of data it is currently dealing with as well as projected growth over the next 5 years.

 

The current Facebook application has millions of users and many billions of status updates and other interaction data. It is expected a steady growth of 10% increase annually.

 

 
100% Plagiarism Free & Custom Written, Tailored to your instructions