Write statements in sql for the given queries

Assignment Help Database Management System
Reference no: EM131900094

Hired by the City of Metropolis to design a database for the Metropolis Transit Authority (META), which runs the city's subway system. The system consists of a number of subway stations, each with a name, and a number of subway lines that connect various stations. Each line runs in two directions, called uptown and downtown. Of course, every day there are many trains on each line. For simplicity, assume that each train has some time when it departs from the first station, and that if the following train starts say 6 minutes later, it will arrive 6 minutes later than the previous train on every station that is on this line. Thus, to store the schedule, you only have to store the starting time of each train, and the times in takes between the stations on the line (which is the same for all trains.)

Customers have to purchase a transit card called METACard to use the subway, and the card can be refilled with credits as needed. Assume that customers have to swipe this card whenever they enter or exit a station, and that the system then deducts from their card the cost of the trip, which depends on where they enter and leave the subway. For example, a trip from "Luthor Avenue" to "Lois Lane" might cost $2, while a trip from "Metro Square" to "Park Avenue" costs $2.50. So the price might be different between any two stations. METACards are identified by an ID, but do not have a customer name associated with them since they can be bought at any newsstand without giving a name. The balance for each card has to be maintained in your database, so that the actual card only stores an ID that is read and transmitted to the database system when the card is swiped.

a) Design an ER diagram that can model the above scenario. Identify any weak entities, suitable keys, and the cardinalities of the relationships. Discuss any assumptions that you are making in your design.

b) Write statements in SQL for the following queries. Note that if your schema does not allow you to answer a query, you may have to go back and change your design.

1. List the names of station where the train departed within the last hour.

2. Assuming that there is a direct train going from "Metro Square" to "Broadway", output the travel time and cost of the trip.

3. For each subway station, output how many people swipe in and out between 8pm and 10pm on Feb 16.

4. Check if there is a way to go from "Metro Square" to "Lois Lane" by changing at most once.

5. Output the customer who took the train from same station at least twice on the same day.

Reference no: EM131900094

Questions Cloud

Define and summarize the architectural innovations : Define and summarize the architectural innovations that lead to the dome in the Newgrange tombs and tholos tombs
Describe the primary value chain activities : Imagine that you have an online business that you use to recruit potential employees for a network of businesses and organizations.
What is meant by voluntary export restraints : What is meant by voluntary export restraints, and how do they differ from other protective barriers? How does the revenue effect of an import quota differ?
Characteristics of the hero aeneas as presented in vergil : What are the main characteristics of the hero Aeneas as presented in Vergil's Aeneid? Does he seem to change from the beginning of the poem to the end?
Write statements in sql for the given queries : Design an ER diagram that can model the above scenario. Identify any weak entities, suitable keys, and the cardinalities of the relationships.
Discuss the definition of organizational behavior : This week, our text discusses the definition of organizational behavior, and in particular, its applied focus. Our lesson focuses on high-performance.
What problems does terrorism pose for globalization : Identify some of the major challenges confronting the international trading system. What problems does terrorism pose for globalization?
Protestant artistic responses to martin luther reformation : Discuss the various Protestant artistic responses to Martin Luther's Reformation. What are the ways in which protestant values and beliefs can be expressed
How can an employer monitoring policy impact communities : How can an employer Monitoring Policy impact diverse communities and explain any limitations that such a policy may need to overcome.

Reviews

Write a Review

Database Management System Questions & Answers

  Knowledge and data warehousing

Design a dimensional model for analysing Purchases for Adventure Works Cycles and implement it as cubes using SQL Server Analysis Services. The AdventureWorks OLTP sample database is the data source for you BI analysis.

  Design a database schema

Design a Database schema

  Entity-relationship diagram

Create an entity-relationship diagram and design accompanying table layout using sound relational modeling practices and concepts.

  Implement a database of courses and students for a school

Implement a database of courses and students for a school.

  Prepare the e-r diagram for the movie database

Energy in the home, personal energy use and home energy efficiency and Efficient use of ‘waste' heat and renewable heat sources

  Design relation schemas for the entire database

Design relation schemas for the entire database.

  Prepare the relational schema for database

Prepare the relational schema for database

  Data modeling and normalization

Data Modeling and Normalization

  Use cases perform a requirements analysis for the case study

Use Cases Perform a requirements analysis for the Case Study

  Knowledge and data warehousing

Knowledge and Data Warehousing

  Stack and queue data structure

Identify and explain the differences between a stack and a queue data structure

  Practice on topic of normalization

Practice on topic of Normalization

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd