UC3M

Telematic/Audiovisual Syst./Communication Syst. Engineering

Systems Architecture

September 2017 - January 2018

10.4.  Establihshing the relationships among different tables in the application

In multiple occasions, there are relationships among the different tables that are present in the application, and this must be reflected in the data model. For example, in the reference application, there is a relationship between the photo and author tables, because each photo has an author. A possible solution, different to the proposed one, would have been to have a single PHOTOS table where all the fields of the authors table will be included, in addition to the ones of the photos table. But this solution would be very inefficient, because there are photos that share the same author, so it is not a good idea to replicate the information of the same author several times. On the other hand, if we separate the authors table, we are only using one author instance for all the photos that share this author. For establishing this table relationship, we set a relationship between the AUTHOR_ID fields of both tables, so that both table fields will be related, in a way that the author information of one photo will be available in the authors table that has the same identifier in this field. This is the reason why the AUTHOR_ID field is added to the  authors table. Graphically, this relationship must be represented in the data model, with an arrow for example. Such relationship is called a FOREIGN KEY (FK)

Although no additional relationships will be presented in this material, however other types of relationships between tables can be established.