Course Title: Management Information Systems
Week 2 Focus: MySQL Workbench Tutorial
Instructor: Yuyang Ye
Date: January 27, 2024
Class: Management Information Systems (Sp 2025)
Required Software:
MySQL Server
MySQL Workbench
Installation Notes:
Both can be installed simultaneously on Windows.
Ensure compatibility between MySQL Server (8.0.x) and MySQL Workbench.
Follow video instructions on Canvas for installation steps (for Windows and Mac).
Additional Installations:
MySQL Documentation: Aids in usage and troubleshooting.
Samples and Examples: Provides example databases and queries for practice.
Important: Remember the MySQL root account password. Recovery can be difficult if lost.
Client-Server Model:
Database Server handles data storage and management.
Clients interact with the server to query and update the database.
Preferences:
Large companies typically run the database on a separate computer.
Smaller setups may run both on a single machine for convenience.
GUI Overview:
MySQL Workbench provides a graphical interface to connect to the database server.
Uses include:
Database and table management
Data viewing and addition
Writing SQL queries
Connection Steps:
Click on "Local Instance MySQL80" in the MySQL Connections list.
If not visible:
Click the "+" icon next to "MySQL Connections" to create a new connection.
Click "Ok" to proceed with connection setup.
After connection, to create a database:
Select the "Schemas" tab to view local databases.
Example Schemas:
Expand the schema and tables sections to view installed tables.
If steps followed correctly, example schemas will populate.
To view table rows:
Right-click table name (e.g., "city") and click "Select rows - limit 1000".
A simple SELECT SQL query will display the first 1000 rows in the top window.
Right-click on a table name and select "Alter Table" for modifications.
Options include viewing and changing the following:
Table name
Columns
Constraints
Indexes
Foreign keys
Data Representation:
Numeric Data: Sales figures, temperatures, stock prices.
Discrete (e.g., products sold) vs. Continuous data (e.g., temperatures)
Textual Data: Customer reviews, social media posts, emails.
Visual Data: Images, videos, graphs.
Audio Data: Sound recordings, music.
Overview of data types to be discussed in subsequent pages.
Definition: Whole numbers without fractional parts, stored in 4 bytes.
Range: -2,147,483,648 to 2,147,483,647.
Variants exist for different ranges (see MySQL Manual).
Definition: Numbers stored as a base and exponent, using 8 bytes.
Exponent range: -1022 to 1023.
Less precision than INTEGER or DECIMAL.
Example: 1/3 produces a repeating fraction.
Stores exact numbers with a fractional part.
Format: DECIMAL(N,D) means N digits total with D after the decimal.
Example: DECIMAL(4,2) can store 65.99 but not 165.1.
Format: YYYY-MM-DD hh:mm:ss
Example: "2024-05-15 09:39:22"
Format: YYYY-MM-DD
Example: "2024-05-15"
Definition: String containing variable characters, up to N.
Example: VARCHAR(5) can store "hello" but not "goodbye".
Definition: String of varying lengths, not usable for keys.
Example: "hello and goodbye"
Definition: Logical values TRUE or FALSE, stored as 1 or 0 (1 byte).
Example: TRUE
Guidance on MySQL data types, noting differences in how they may be displayed.
Focus on understanding abbreviations like INT for INTEGER.
Reference MySQL Official Documentation and examples in MySQL Workbench.
Introduction to examples of data types in MySQL Workbench.
Tips for obtaining better responses:
Ask clear, specific questions.
Ensure understanding of responses.
Verify accuracy through multiple sources.
Examples of good questions for effective outcomes.
Good: Asking for definitions and examples of data types.
Bad: Asking generic or vague questions.
Overview of numeric data types such as INT, DECIMAL, FLOAT, and DOUBLE.
Overview of string data types including CHAR, VARCHAR, and TEXT.
Overview of date and time data types: DATE, TIME, DATETIME, and TIMESTAMP.
Introduction to BLOB and its variants for binary data storage.
Overview of BOOLEAN, ENUM, and SET data types.
Explanation of customizing MySQL data types with options such as UNSIGNED and ZEROFILL.
Steps for adding data to existing tables:
Open Table View and select a table.
Edit data directly in the view.
Save changes and confirm SQL commands.
Steps to remove data:
Select the row to remove and confirm deletion.
Option to revert changes if necessary.
Steps to write and execute SQL queries in MySQL Workbench:
Open a new query tab and select target database.
Execute query with the yellow bolt icon.
Example SQL query structure:
SELECT All columns (*) from "world(database).city(table)".