Activity 4: Research MySQL

Step 1: Research the Basics of MySQL

What is MySQL?

  • MySQL is an open-source relational database management system (RDBMS) that uses structured query language (SQL) to manage data in a structured way.

  • It is essential for web applications as it stores and organizes large amounts of data for websites, such as user information, products, and orders.

Key Terms:

  • Database: A collection of data that is stored in an organized manner.

  • Tables: Structures within a database that store data in rows and columns.

  • Columns: Define the types of data (e.g., name, age) stored in a table.

  • Rows: Individual records in a table (e.g., one person’s data).

  • Optional: Install MySQL if you want to practice hands-on by following online tutorials.

Step 2: Understanding Databases and Tables

  • Databases: A database is a system for storing and managing data in an organized and accessible way.

  • Tables: Tables represent data in rows and columns, where each column defines a type of data (like name, age), and each row is a unique entry (like a person or product).

Step 3: Learn Basic MySQL Commands

  • Creating a Database:

      CREATE DATABASE my_database;
    
  • Creating a Table:

      CREATE TABLE my_table (
        id INT AUTO_INCREMENT PRIMARY KEY,
        name VARCHAR(100),
        age INT
      );
    
  • Inserting Data:

      INSERT INTO my_table (name, age) VALUES ('John Doe', 30);
    
  • Updating Data:

      UPDATE my_table SET age = 31 WHERE name = 'John Doe';
    
  • Querying Data:

      SELECT * FROM my_table WHERE age = 31;
    
  • Deleting Data:

      DELETE FROM my_table WHERE name = 'John Doe';
    

Step 4: Study Data Types in MySQL

Common Data Types:

  • INT: Used for whole numbers.

  • VARCHAR: Stores variable-length strings.

  • DATE: Stores date values.

  • TEXT: Stores large text data.

Step 5: Explore MySQL Relationships

Primary Keys: A unique identifier for each record in a table.

Foreign Keys: A reference to a primary key in another table.

  • Relationships:

    • One-to-One: Each record in Table A corresponds to one record in Table B.

    • One-to-Many: A record in Table A can correspond to multiple records in Table B.

    • Many-to-Many: Records in Table A and Table B can correspond to multiple records in each other.

Step 6: Research MySQL Indexing

  • Indexing: Improves the speed of data retrieval by creating indexes on columns frequently queried. It enhances performance in large datasets.

Step 7: Security in MySQL