MySQL Practical 1 Summary
MySQL Practical 1 - Introduction
Objectives
- Install MySQL
- Create a database using forms
- Create tables using forms
- Insert records using forms
MySQL Installation Instructions
- Download XAMPP from https://sourceforge.net/projects/xampp/
- XAMPP includes: Apache web server, MySQL, PHP, Perl, FTP server, phpMyAdmin.
- Use XAMPP Control Panel to start/stop MySQL and test projects.
About phpMyAdmin
- Open-source tool for managing MySQL databases via a web interface.
- Facilitates database operations (CRUD: create, retrieve, update, delete).
Creating a Database
- Launch XAMPP Control Panel.
- Start Apache and MySQL modules.
- Access phpMyAdmin at http://localhost/phpmyadmin.
- Click on Database tab.
- Enter "School" as database name (max 64 characters).
- Click Create.
Creating Tables
- Tables in MySQL store structured information.
- In School database, click Structure tab and Create Table.
- Table Name: "Lecturer", Columns: 2.
- Define columns:
- LNum (Primary Key, Numeric, length 4)
- LName (String, length 20)
- Click Go, then SAVE.
Inserting Records in Teacher Table
- Use given data to insert records:
- LNum and LName pairs.
- Click Insert and type the number of records (4).
- Fill in values and press Go.
Creating Course Table
- Columns: CNum (Primary Key), CName, LNum (Foreign Key).
- Create Table: "Course", Columns: 3.
- Set CNum as Primary Key, LNum as Foreign Key (must match Lecturer's LNum).
- Define record data types.
Specifying Foreign Key Constraints
- Click Relation View tab for Course table.
- Set foreign key constraints (RESTRICT, CASCADE, SET NULL for parent table operations).
- Use specified data to insert Course records (ensure matching LNum).
Viewing Tables
- Use Browse to view structure and records of Lecturer and Course tables.