Access your own database
You access Aminer on the 2022 server at the following address: (notice the port number, 12322, after the colon in the url)
Each of you already has an account on the server. Your Username is your student ID. The password was given to you in class. At the login form, enter your credentials, and you should be able to get in. (If you encounter problems accessing Adminer, let me know right away. You need this to complete every assignment in this class.)
After logging in, you should see something like the image below. Adminer looks a bit weird, and the interface is messy, but you’ll get used to it. On this screen, you must select your database. You should see a database called db[your student id]. In the screenshot, it is db1111111. Click on this link, it will bring you to your database. All the tables you will create in this class for your apps will be in this database.
This is the main Adminer interface. I will explain the parts you need to look for and use as you need them. Again, this may look odd to you, but you will get familiar with the main elements quickly. It is quite simple.
You will notice right away that you have two tables already in your database. I created those. You can ignore them for now. If you are curious and check them out, it contains the family tree of Kanye West and Kim Kardashian. (It is possible that you have more tables, especially if you took this class before. Don’t worry about it.)
Create the table
Here we will create the table we have designed after our analysis of the mandate: the album table.
Click on Create table. You will find this button at two locations, I have marked them with arrows above, click one or the other, it does not matter. You will be presented with the table creation tool. (I’m going to crop the image from now on to focus on the tool we use.)
At the top of the tool, you will see a field where you can type the name of the table. And below, there is the control where you can create the columns for this table.
Enter the name of the table: album.
Next, we will create the first column: id. For this one, you need to pay attention. We will do two things that are very important, and that you will need to do for every table you create in this class, and probably ever in your life: set the id column’s data type to int() and set the column to auto increment.
WHAT? Auto increment means that the column will be assigned a value automatically by the database system. Since the id column is used to indentify every individual entry in the table, each entry must have a unique id value. The only way of assuring this, is to have that value created by the system. So every time a new entry is added, it gets assigned a new value of id which is 1 plus the previous value. Later, when we start adding data in the table, you will understand.
OK, so your id column definition should look like this:
Pay attention to the three elements marked by an arrow. Starting left, the first arrow is the name of the column. This should be straight forward, but be careful, you cannot have spaces in the name. no spaces Next you have the data type. This is a drop down menu of all the available data types in MySQL. Find and select int (for interger). (Note that Adminer will select it for you if you name the column “id”.
The third arrow is super important. This is how you set the column as auto increment in Adminer. This also makes the column the primary key. We will talk about keys later in the semester when we make relational databases, but for now just remember the auto increment feature. Make sure the field is checked, but only for the id column, not the others.
Now you can create the other columns. Follow the data model we created above. The other columns are not auto increment, so the AI field should not be checked for them. You just give them a name and a data type. You will notice that as soon as you start naming a column, Adminer creates the fields for you to add another one. So it is quite quick. Your final setup should look like this:
Notice that the varchar columns have a number below Length. This is the size of the column. For now, you can write 255 like my example. You can now click Save.
Your table has been created, and you should see this:
You see how similar the presentation of the table’s definition is to the data model. This is not a surprise. ;-)
I encourage you to click on the button that says SQL Command in the green area. (If you see it, it does not alway appear.) This will show you the command that was sent to the server in order to create this table. Every time you do anything in Adminer, the tool generates some code that is sent to the server to do what you ask. And you can see that code. It is a great way of learning the SQL language which your apps are also going to use to communicate with the database.
Bravo! You have created a database table! OMG!