Create the following table in your database with the following schema: Table: Users +- | Column Name 1 Туре +- | id | name | int I varcharI ----+ id is the primary key for this table. name is the name of the user. Table: Rides | Column Name 1 Туре +- | id I user_id I distance | int | int | int +- id is the primary key for this table. user_id is the id of the user who traveled the distance "distance". Add the following data to your tables: Input: Users table: +----- | id | name | 1 | 2 | 3 | 4 | Alice | Bob | Alex | Donald I Lee

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

i want the codes of create table and insert table only please

Create the following table in your database with the following schema:
Table: Users
| Column Name
| Туре
+-
+-
| int
| varchar |
| id
| name
+-
id is the primary key for this
table.
name is the name of the user.
Table: Rides
| Column Name
| туре
+-
| id
| user id
| distance
| int
| int
| int
+-
id is the primary key for this
table.
user id is the id of the user who traveled the distance "distance".
Add the following data to your tables:
Input:
Users table:
+------+
| id
| name
+-
| 1
| 2
| 3
| 4
| 7
| 13
| 19
| Alice
| Bob
| Alex
| Donald
| Lee
| Jonathan
| Elvis
+----
Rides table:
+------
| id
I user id
| distance |
+-----
+---
| 1
| 2
| 3
| 4
| 5
| 1
| 2
| 3
| 7
| 13
| 19
| 120
| 317
| 222
| 100
| 312
50
| 120
| 400
| 230
| 8
| 19
+-----
Transcribed Image Text:Create the following table in your database with the following schema: Table: Users | Column Name | Туре +- +- | int | varchar | | id | name +- id is the primary key for this table. name is the name of the user. Table: Rides | Column Name | туре +- | id | user id | distance | int | int | int +- id is the primary key for this table. user id is the id of the user who traveled the distance "distance". Add the following data to your tables: Input: Users table: +------+ | id | name +- | 1 | 2 | 3 | 4 | 7 | 13 | 19 | Alice | Bob | Alex | Donald | Lee | Jonathan | Elvis +---- Rides table: +------ | id I user id | distance | +----- +--- | 1 | 2 | 3 | 4 | 5 | 1 | 2 | 3 | 7 | 13 | 19 | 120 | 317 | 222 | 100 | 312 50 | 120 | 400 | 230 | 8 | 19 +-----
Return the result table ordered by travelled_distance in descending order, if two or more users traveled
the same distance, order them by their name in ascending order.
Hint: Use IFNULL(a,b) function in your select clause where a is the value that should be returned and
b is the value that should be returned if a is NULL.
The result should be:
Output:
| name
travelled distance
+--
| Elvis
| Lee
| Bob
| Jonathan | 312
| Alex
| Alice
| Donald
| 450
| 450
| 317
| 222
| 120
+-
Explanation:
Elvis and Lee traveled 450 miles, Elvis is the top traveler as his name is
alphabetically smaller than Lee.
Bob, Jonathan, Alex, and Alice have only one ride and we just order them by the
total distances of the ride.
Donald did not have any rides, the distance traveled by him is 0.
Transcribed Image Text:Return the result table ordered by travelled_distance in descending order, if two or more users traveled the same distance, order them by their name in ascending order. Hint: Use IFNULL(a,b) function in your select clause where a is the value that should be returned and b is the value that should be returned if a is NULL. The result should be: Output: | name travelled distance +-- | Elvis | Lee | Bob | Jonathan | 312 | Alex | Alice | Donald | 450 | 450 | 317 | 222 | 120 +- Explanation: Elvis and Lee traveled 450 miles, Elvis is the top traveler as his name is alphabetically smaller than Lee. Bob, Jonathan, Alex, and Alice have only one ride and we just order them by the total distances of the ride. Donald did not have any rides, the distance traveled by him is 0.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY