Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

02- MySQL - Tables

The document provides a step-by-step guide for creating tables in MySQL, including instructions on creating schemas and defining data types. It outlines important notes regarding naming conventions, primary keys, and optional attributes. Additionally, it explains how to establish relationships between tables using primary and foreign keys.

Uploaded by

cawote1850
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

02- MySQL - Tables

The document provides a step-by-step guide for creating tables in MySQL, including instructions on creating schemas and defining data types. It outlines important notes regarding naming conventions, primary keys, and optional attributes. Additionally, it explains how to establish relationships between tables using primary and foreign keys.

Uploaded by

cawote1850
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Ms.

Mary William

MySQL

(MySQL Administrator)

Creating Tables on MySQL:

1. Open “MySQL administrator”


2. Click on “catalogs” (my database)
3. Choose “Schema” to create your own database.
4. Right click on the white area at the left corner.
5. Click on “Create new Schema” and rename it.
6. Click on your own database from the left side.
7. Click on “Create table” then rename the table.
8. Type the attributes in the column Name and Datatypes.

Data Types:

- Integer (default value) for numbers.


- Varchar (45) changeable and expandable.
- DataTime can be only Date or only Time.
- ENUM ('M','F') Boolean YES/NO, True/False.
- Decimal (2,2) Digit, Decimal
- Text for comments

Important notes:

- No spaces are allowed use underscore instead.


- Primary key is always the first attribute to add and the key is shown on
the left.
- If you want an optional attribute -- remove the not null sign.

1
Ms. Mary William

Create relationship between entities:

1. create all tables first.


2. Open the one side table.
3. Copy the primary key of the one table.
4. Open the many side table.
5. Paste the foreign key (same name, same datatype, same length)
6. In the many table open foreign key tab (at the bottom of the page)
a) From the (+) sign
b) add new key – rename it to an understandable one
c) choose reference table (to which table are you referring – source
of the foreign key)

Column Ref. Column

The "FK" you pasted The original "PK"

 on Delete -- Cascade
 on update -- Cascade

You might also like