Module 9: Creating My First MySQL Table
For this module, I worked inside InfinityFree’s control panel and phpMyAdmin to create my first MySQL table. This was a simple assignment, but it’s a key piece of understanding how PHP and databases connect later on. My database is named module9_db, and I built a table called users with an auto-incrementing ID and two text fields for first and last names.
Step 1 – Creating the Database
I started in my InfinityFree account under MySQL Databases and clicked Create New Database. InfinityFree automatically adds its account prefix, so the final name looked like if0_39835771_module9_db. The process itself was straightforward, no configuration needed beyond giving it a name.
Step 2 – Designing the Table in phpMyAdmin
Next, I opened phpMyAdmin from the panel to design the table. I named it users and added three fields:
- id – INT(11), set as the Primary Key and Auto Increment
- firstname – VARCHAR(50)
- lastname – VARCHAR(50)
Choosing the right data types was the main point here. INT is used for numeric IDs that can increment automatically, while VARCHAR is for variable-length text. The interface is a bit cluttered at first, but once you know where to set the Primary Key and Auto Increment options, it’s pretty smooth.
Step 3 – Inserting Data
After saving the table, I clicked on the Insert tab and added a test record:
firstname = Drew, lastname = Williams.
phpMyAdmin ran the following SQL automatically:
INSERT INTO `users` (`firstname`, `lastname`)
VALUES ('Drew', 'Williams');
Then, under the Browse tab, I could see the new row with an ID of 1.
The easiest part was creating the database, InfinityFree does most of the setup for you. The only thing that took a second to think through was which data types made the most sense for the fields. phpMyAdmin gives a lot of options, so it’s easy to overthink, but sticking to INT for numeric keys and VARCHAR for names worked perfectly.
Overall, this module was a good hands-on refresher in basic SQL table design. Even though I’ve worked with databases before, going through the process manually in phpMyAdmin helps reinforce what’s actually happening behind the code, every “create table” and “insert” in the GUI is just building and executing SQL in the background.
Comments
Post a Comment