users and videos—and added primary keys, foreign keys, data types and relationships.
Now we’ll convert that spreadsheet into a relational database using MySQL. In this lesson you’ll learn what CRUD means, create a new database, and run basic SQL to Create, Read, Update and Delete records.
What is CRUD?
- CRUD stands for Create, Read, Update, Delete. These are the four fundamental operations any application or service performs on persistent data.
- SQL (Structured Query Language) is the standard language you use to perform CRUD operations in a relational DBMS like MySQL.

- We’ll use MySQL in the KodeKloud Playground (or your local MySQL instance). The playground provides login details and an interactive MySQL shell.
- If you need help in the MySQL client, use the built-in
HELPcommand or consult the official MySQL documentation.
- A database in MySQL is a logical namespace that holds tables and other objects. Create a database, list available databases, and switch to the new one:
CREATE DATABASE miaowtube;creates an empty database namedmiaowtube.SHOW DATABASES;lists all databases on the server.USE miaowtube;selects the database for subsequent commands.SELECT DATABASE();confirms the current database.
users first?
- The
videostable referencesusers.user_idwith a foreign key. MySQL requires the referenced table to exist when adding a foreign key (unless both are created in a single statement where supported). Creatingusersfirst avoids needing an extraALTER TABLElater.

- Use
INT AUTO_INCREMENT PRIMARY KEYforuser_idandvideo_idso the database assigns unique IDs automatically. VARCHAR(100)forusernameandtitle.VARCHAR(500)forlinkto safely store longer URLs.VARCHAR(255)foremail(common, index-friendly choice).DATEforupload_date(format YYYY-MM-DD).- Use
InnoDBengine for foreign key support. ON DELETE CASCADEon the foreign key ensures referential integrity by removing related videos if a user is deleted (only use this if that is the desired behavior).
INT AUTO_INCREMENT PRIMARY KEY— auto-incrementing integer primary key.VARCHAR(n)— variable-length string up to n characters.NOT NULL— value is required in that column.DATE— storesYYYY-MM-DD.FOREIGN KEY (user_id) REFERENCES users(user_id)— enforces that everyuser_idinvideosexists inusers.ON DELETE CASCADE— deletes dependentvideosrows when the referencedusersrow is removed.ENGINE=InnoDB— required for foreign key enforcement in MySQL.
Column types and rationale
Tips for using the MySQL client
- If you make a typo while entering a long statement, press Ctrl-C to cancel the current input.
- Alternatively, finish the statement with a semicolon, then use your shell history (up-arrow) to retrieve and edit previous commands.
- Use
DESCRIBE table_name;orSHOW CREATE TABLE table_name;to inspect table definitions.
If you need to add a foreign key after creating both tables, use ALTER TABLE to add the constraint. However, creating the referenced table first avoids extra ALTER steps.
- MySQL Documentation: https://dev.mysql.com/doc/
- Kubernetes Documentation (for related deployment topics)
- KodeKloud Playground (use the playground for interactive MySQL practice)