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