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

  1. Launch XAMPP Control Panel.
  2. Start Apache and MySQL modules.
  3. Access phpMyAdmin at http://localhost/phpmyadmin.
  4. Click on Database tab.
  5. Enter "School" as database name (max 64 characters).
  6. Click Create.

Creating Tables

  • Tables in MySQL store structured information.
  1. In School database, click Structure tab and Create Table.
  2. Table Name: "Lecturer", Columns: 2.
  3. Define columns:    - LNum (Primary Key, Numeric, length 4)    - LName (String, length 20)
  4. Click Go, then SAVE.

Inserting Records in Teacher Table

  1. Use given data to insert records:    - LNum and LName pairs.
  2. Click Insert and type the number of records (4).
  3. Fill in values and press Go.

Creating Course Table

  • Columns: CNum (Primary Key), CName, LNum (Foreign Key).
  1. Create Table: "Course", Columns: 3.
  2. Set CNum as Primary Key, LNum as Foreign Key (must match Lecturer's LNum).
  3. Define record data types.

Specifying Foreign Key Constraints

  1. Click Relation View tab for Course table.
  2. Set foreign key constraints (RESTRICT, CASCADE, SET NULL for parent table operations).
  3. Use specified data to insert Course records (ensure matching LNum).

Viewing Tables

  • Use Browse to view structure and records of Lecturer and Course tables.