5. 2. Challenge
Defining the reference table
A mysql prompt has been opened for you.
Using the college database, complete the following tasks (use either a single-line or a multi-line SQL statement):
Create a courses table with this definition (try using a multi-line SQL statement):
+---------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------+---------------------+------+-----+---------+----------------+ | id | int(3) unsigned | NO | PRI | NULL | auto_increment | | title | varchar(255) | NO | UNI | NULL | | | credits | tinyint(2) unsigned | NO | | 1 | | +---------+---------------------+------+-----+---------+----------------+
SQL Statements to Copy:
The SQL statement to create a table “course” in the college database is as follows:
USE college;
CREATE TABLE courses(
id INT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
credits TINYINT(2) UNSIGNED NOT NULL DEFAULT 1,
PRIMARY KEY(id),
UNIQUE KEY(title)
);
NOTE:
1) Before executing the SQL query, create a college database using
CREATE DATABASE college;
2) These sql statements will run on PhpMyAdmin or MY SQL but might not work on the online sql compiler.
5. 2. Challenge Defining the reference table A mysql prompt has been opened for you. Using...
9.3. Challenge Altering tables A mysql prompt has been opened for you. Using the EPDriver database 1. Change the name of the name column of the drivers table to driver_name with a VARCHAR data type and a 125 character limit that can't be null 2. Add a new driver_age column to the drivers table with a TINYINT (2) data type that must not be a negative value and can't be null 9.3. Challenge Altering tables A mysql prompt has been...
Create a classrooms table with this definition (try using a multi-line SQL statement): +-----------+-----------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+-----------------+------+-----+---------+----------------+ | id | int(3) unsigned | NO | PRI | NULL | auto_increment | | room_num | int(4) unsigned | NO | UNI | NULL | | | course_id | int(3) unsigned | YES | MUL | NULL | | +-----------+-----------------+------+-----+---------+----------------+
MySQL 11. Final challenges Reset challenge database If you make a mistake while editing the database in this section or just want to reset the database back to its original state, return to this page and click the “Reset Section Database” button below. RESET CHALLENGE DATABASE If I have seen further, it is by standing on the shoulders of giants. (Bernard of Chartres). Databases are fun. Let’s honour some of the most popular scientists of all times by creating a...
Query the apartment table and find nearby restaurants with in 200 meters distance. I have two tables one gives the home adressses and second has near by businesses with latitude and longitude given. I need to find restaurants nearby the adress with in 200 meters. Each business also has longitude/latitude information, we can get the database to calculate distances to various useful points close by to each apartment. So we have two tables 1. Apartments and no 2 is business....
stuck on creating view Use a SQL statement to create a view vIBM_MMM (year, month, IBM_price, MMM_price) that contains the year and month, average close prices of IBM and MMM for the year/month. Your view should directly access the Historial_price table to have the latest data. mysql> desc Historical_prices; +-----------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+----------------+ | id | bigint(20) | NO | PRI | NULL | auto_increment | | symbol |...
IN THE PREVIOUS CHAPTER WE MADE A DATABASE USING OUR LAST NAME AS ITS NAME. QUESTION 1 STATES THIS. PLEASE TYPE WHAT NEEDS TO BE TYPED FOR ALL STEPS. THIS USES CODIO a. 1. Connect to the database you created and named in Module One (for example, Jetson). Type after the prompt mysql> a. use (table you named); i. Example: mysql> use Jetson; 2. Create the Employee table using the SQL statement shown here. Press Return after each line. CREATE...
11. For each song in the songs table, update the value of artist_id to the id of the corresponding artist in the artists table. 11.1. You must update all songs using only one UPDATE statement and a subquery. Hardcoded ids or names are not allowed in your query. 12. For each song in the songs table, update the value of genre_id to the id of the corresponding genre in the genres table. 12.1. You must update all songs using only...
Database HW help!!!!!!! Provide the SQL statements for the following queries. (1) Provide the names and phones of all swimmers currently in level (of id) 3. +-------+---------+---------------------------+ | FName | LName | EMail | +-------+---------+---------------------------+ | Bobby | Khan | theBKhan1 | | Clara | Johnson | ClaraJohnson_11 | +-------+---------+---------------------------+ 2 rows in set (0.00 sec) (2) Provide the names of swimmers who have signed up to participate in the event '100M Butterfly' of Meet id 1. +-------+---------+ | FName...