Record Movie Data Challenge

MySQLMySQLBeginner
Practice Now

Introduction

A local cinema needs help setting up their movie database. As their database administrator, you need to insert some movie data into their existing database. This challenge tests your ability to insert data into a MySQL table using proper SQL syntax.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL mysql(("MySQL")) -.-> mysql/BasicKeywordsandStatementsGroup(["Basic Keywords and Statements"]) sql(("SQL")) -.-> sql/BasicSQLCommandsGroup(["Basic SQL Commands"]) mysql(("MySQL")) -.-> mysql/DatabaseFunctionsandDataTypesGroup(["Database Functions and Data Types"]) sql(("SQL")) -.-> sql/DataDefinitionandIntegrityGroup(["Data Definition and Integrity"]) mysql/BasicKeywordsandStatementsGroup -.-> mysql/use_database("Database Selection") sql/BasicSQLCommandsGroup -.-> sql/insert("INSERT INTO statements") mysql/BasicKeywordsandStatementsGroup -.-> mysql/insert("Data Insertion") mysql/DatabaseFunctionsandDataTypesGroup -.-> mysql/int("Integer Type") mysql/DatabaseFunctionsandDataTypesGroup -.-> mysql/varchar("Variable Character Type") sql/DataDefinitionandIntegrityGroup -.-> sql/data_types("Data Types") subgraph Lab Skills mysql/use_database -.-> lab-418302{{"Record Movie Data Challenge"}} sql/insert -.-> lab-418302{{"Record Movie Data Challenge"}} mysql/insert -.-> lab-418302{{"Record Movie Data Challenge"}} mysql/int -.-> lab-418302{{"Record Movie Data Challenge"}} mysql/varchar -.-> lab-418302{{"Record Movie Data Challenge"}} sql/data_types -.-> lab-418302{{"Record Movie Data Challenge"}} end

Insert Movie Records

The cinema needs you to add their current movie lineup to the database. You will practice inserting multiple rows of data into a MySQL table.

Tasks

  • Connect to MySQL as the root user
  • Use the cinema database
  • Insert the following three movies into the movies table:
    1. Avatar (2009) - Science Fiction - $12.99
    2. The Dark Knight (2008) - Action - $11.99
    3. Inception (2010) - Science Fiction - $12.99

Requirements

  • All operations must be performed in the ~/project directory
  • Use the correct SQL INSERT syntax
  • All movies must be inserted in a single SQL statement
  • The title and price fields cannot be NULL
  • Years must be inserted as numbers, not strings
  • Insert the data in the exact order specified in Tasks

Example

After inserting the data correctly, running SELECT * FROM movies; should show:

+----+-----------------+--------------+-----------------+-------+
| id | title           | release_year | genre           | price |
+----+-----------------+--------------+-----------------+-------+
|  1 | Avatar          |         2009 | Science Fiction | 12.99 |
|  2 | The Dark Knight |         2008 | Action          | 11.99 |
|  3 | Inception       |         2010 | Science Fiction | 12.99 |
+----+-----------------+--------------+-----------------+-------+
โœจ Check Solution and Practice

Summary

In this challenge, you practiced inserting multiple rows of data into a MySQL table. The skills demonstrated include connecting to a MySQL database, using proper SQL INSERT syntax for multiple records, handling different data types correctly, and ensuring data accuracy. These fundamental data insertion skills are essential for database management and will be used frequently when working with MySQL databases.