Presentation is loading. Please wait.

Presentation is loading. Please wait.

RDBMS MySQL. MySQL is a Relational Database Management System MySQL allows multiple tables to be related to each other. Similar to a Grandparent to a.

Similar presentations


Presentation on theme: "RDBMS MySQL. MySQL is a Relational Database Management System MySQL allows multiple tables to be related to each other. Similar to a Grandparent to a."— Presentation transcript:

1 RDBMS MySQL

2 MySQL is a Relational Database Management System MySQL allows multiple tables to be related to each other. Similar to a Grandparent to a parent, a parent to child and so forth.

3 Table Fields When you create a table make the first field an int, unsigned, auto increment and primary key – Ints are whole numbers – Unsigned are numbers that are positive only – Auto increment set the table to automatically add a new number in this field every time a new record is added to the next available number – Primary key means that the field is easily searched on and each record has a unique value.

4 Table Fields for Child Tables If you have a child table the second field should be a foreign key – Foreign key field names are based on the table name and the field name manufactuer_id – The field type should be the same as the primary key of the parent table – Index this field – Other fields should then follow.

5 Basic Flat table A flat table with manufacturer, product and comments. Basic until you start adding more data

6 Basic Flat table More data Issues with duplicate info Table data sizes increases

7 Basic Flat table Data may not be the same or inconsistent

8 Normalization The solution of not having a flat table with duplicate data and inconsistent information is to normalize the tables. That is to make multiple tables from the one where data is not duplicated.

9 Normalization Besides making the different tables you need to add the foreign keys Foreign key is a term for a field that is indexed and the values relate to another table.

10 Normalization Besides making the different tables you need to add the foreign keys Foreign key is a term for a field that is indexed and the values relate to another table.

11 The SQL call to retrieve this data is called a JOIN The type of JOIN we will be doing is a straight join using a WHERE clause The names of field now need to be proceeded with the table name. The table name and field is separated with a period. SELECT manufacture.name, product.name FROM manufacturer, product WHERE manufacturer.id = product.manufacturer_id

12 The SQL call to retrieve this data is called a JOIN Additional parts of the WHERE statement can be added as well as ORDER Bys and GROUP BYs


Download ppt "RDBMS MySQL. MySQL is a Relational Database Management System MySQL allows multiple tables to be related to each other. Similar to a Grandparent to a."

Similar presentations


Ads by Google