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…

Scriptcase uses the MVC template?

Maybe you might have thought about this at some point, “Scriptcase uses the MVC templates?" Well, ...

How to implement A2F using Own Development in NodeJS in a Scriptcase application

A2F using Own Development in NodeJS A2F: In a previous article, we talked about Swivel as an extern...

Specialists or generalists, who gets a better advantage by using Scriptcase?

Hey there! Today  we will figure what are the ideal profiles for those who wish to take advantage o...

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.