UC3M

Telematic/Audiovisual Syst./Communication Syst. Engineering

Systems Architecture

September 2017 - January 2018

10.3.  Data modeling in an application

First, one designer might ask himself/herself which is all the needed information for the application taken into account a specification. The information can be divided in the following 2 groups depending on if information instances are allowed or not:

  1. Information that cannot have multiple instances. An example of this type of information in an application might be the system time. The application cannot have different system times in a specific moment, but only one, which of course will change during the time, but there will not be several instances in a time instant. For this type of information, there is the possibility that it is clear from the beginning which is the needed amount of needed memory to store such information (as it is the case of the system time) or that it is not clear from the beginning which is the amount of needed memory to store such information, because it can change (e.g. It can be a string of undefined length).

  2. Information that can have multiple instances. An analogy might be established between instance and object. An example of such type of information in the reference application is the photos, and another one is the authors. This is because, there can be multiple photo and author instances, which are present in the same instant of time. Furthermore, it is usual that the number of instances is not predefined a priori, but it can change along the time, as it is the case of the application reference for the photos and authors.

In order to model each one of the elements that can have multiple instances, a table is used, which will include all the information attributes that can have such element, together with the indication of the data type that corresponds with each attribute. In addition, there is an indication of which field or combination of fields make possible to identify whichever instance of this element, distinguishing it from all the rest of instances. This is called as PRIMARY KEY (PK). For example, the PK for the photos could be a unique identifier, and the PK for the authors could be the combination of the name and surname fields, the one that will identify them uniquely.

The structure of the table storing the photo elements is:

Photo
Field Data type

ID(PK)

Integer

Name

String

File type

Integer

Size

Integer

Author_ID

Integer

The structure of the table storing the author elements is:

Author
Field Data type

Author_ID

Integer

Name (PK)

String

Surname (PK)

String

Age

Integer

Phone

Integer

10.3.1.  Self-assessment questions

Answer the following questions

  1. The field that makes possible to distinguish an instance from all the rest of instances, is called primary key.

    • True

    • False

  2. The primary key could be made of several fields of the table.

    • True

    • False

  3. The PK of the table storing the "author" elements is made of Name and Surname fields. What constraint does will be right to store data into the table?

    • Two authors who have the same name and surname

    • Authors whose names are different