The best way to talk about database relationship is exemplifying their use, certain information often depends on another for it to exist and with that comes the need to create a way to link them. Database Relationships is just that, a way to link the data from one table to another from a certain information.

To make it easier to understand we will use a practical example, imagine categorize all products in a database. Each product must have a category. Then consider the following scenario:

Table: tbl_cat -> Fields: cod_cat, name

Table: tbl_produto -> Fields: cod_prod, cod_cat, Name, Price

Note that the field cod_cat that stores the category code is used to indicate, in the table product, that product belongs to which category. It features a one to many relationship where one category can be used for several products. If it were not possible to create relationships all table information category would have to be included in the product table and it probably would bring future problems if were necessary add more information related to the category.

As quoted above, the type of relationship used was the one to many, but there are still two other types of relationships with them one to one where there is a direct relationship between two primary keys and many to many relationship where it is possible to use multiple records and the same relationship is no possibility of repeating the table.

database

Understand how relationships is essential to model and optimize your database, so it is important to get all requirements and fully understand the role of each information.

You might also like…

PROCESAMIENTO AJAX EN SCRIPTCASE

Ajax en los formularios de Scriptcase puede usarse para recargar un campo de tipo de select basado e...

IMPORTAR IMAGENES DE LA BASE DE DATOS Y UTILIZAR CLASES DE BOOSTRAP

Como muchas personas ya saben, Bootstrap es una biblioteca de front-end libre y de código abierto p...

TENDENCIAS DE DESARROLLO WEB PARA 2017

Usted verá en este post tendencias para 2017 en Diseño Web, en el medio digital y en el desarrollo...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.