1 / 12

RDBMS

RDBMS. MySQL. MySQL. 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. Table Fields.

eunice
Download Presentation

RDBMS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. RDBMS MySQL

  2. MySQL • 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

More Related