This tutorial will teach you how to create a simple movie database that stores information about movies. It will show you how to use SQL commands to insert data into tables, and how to retrieve data using SELECT statements.
Create a table for each type of data we need to store.
In order to build our database, we first need to decide what kind of data we’re going to store. There are three main categories of data that we might want to store: Movie Name, Actor Name, Genre. We’ll start by creating a table called Movies. Each row in this table represents one movie. We’ll then add columns to this table to hold information about the movie itself.
Add columns to our tables.
Let’s take a look at the schema for our Movies table. This table will contain information about each movie. It has four columns: MovieID (Primary key) MovieName Director Genre The primary key column, MovieID, is an auto increment integer value. This means that when we insert new rows into the table, the ID field will automatically generate a unique number for us.
Insert rows into our tables.
Now let’s add some data to our table. First, we need to insert a row with a unique ID. In order to do this, we use the INSERT statement. Here’s what the syntax looks like: INSERT INTO Movies VALUES(?,?,?,?) Here, the first parameter is the name of the table, the second parameter is the name of one of the fields within the table, the third parameter is the value of the field, and the fourth parameter is the type of the field.
Delete rows from our tables.
If we wanted to delete a row from our Movies table, we would use the DELETE statement. This statement takes three parameters. The first parameter is the name (or alias) of the table, the next parameter is the name of a column within the table, and the last parameter is the value of that column.
Update rows in our tables.
In order to update a row in our Movies table, we need to specify what columns we want to update. Let’s say we want to update the title of a particular movie. We’d use an UPDATE statement with two parameters. The first parameter specifies the name of the table, and the second parameter specifies the name of a column.