Write all the sql code (including create, insert and select)
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Write all the sql code (including create, insert and select)

Transcribed Image Text:Create the following tables in your database with the following schema:
Table: Users
I Column Name
| Type
+--
int
I account
| name
| varchar
+--
---+
-----
account is the primary key for this table.
Each row of this table contains the account number of each user in the bank.
Table: Transactions
| Column Name
| Туре
+-
| trans id
I account
| amount
| transacted_on | date
| int
| int
| int
+--
trans id is the primary key for this table.
Each row of this table contains all changes made to all accounts.
amount is positive if the user received money and negative if they
transferred money.
All accounts start with a balance of 0.
Add the following data to your tables:
Input:
Users table:
+---
I account
I name
+---
| 900001
| 900002
| 900003
| Alice
| Bob
| Charlie
Transactions table:
+--
| trans id
| account
| amount
| transacted_on
+---
| 1
| 2
| 3
| 900001
| 900001
| 900001
I 900002
| 900003
| 900003
| 900003
| 7000
I 7000
| -3000
| 1000
| 6000
| 6000
| -4000
2020-08-01
2020-09-01
2020-09-02
2020-09-12
5
2020-08-07
2020-09-07
| 7
2020-09-11
+--

Transcribed Image Text:Write an SQL query to report the name and balance of users with a balance higher than 10000. The
balance of an account is equal to the sum of the amounts of all transactions involving that account.
Return the result table in any order.
The results should be:
Output:
I name
balance
| Alice
11000
Explanation:
Alice's balance is (7000 + 7000 -
Bob's balance is 1000.
3000) = 11000.
Charlie's balance is (6000 + 6000
4000) = 8000.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education