Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions 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
+-----
expand button
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.
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY