UC3M

Telematic/Audiovisual Syst./Communication Syst. Engineering

Systems Architecture

September 2017 - January 2018

10.11.2.  Data Modeling

Resources

Work Plan

The objective of this activity is to introduce you in the data modeling of a software application, so that you can extend the knowledge about which data you should model, how to model it, the different options for real implementation of a data model, implications for writing program code, the importance of the layer separation, etc. In this way, you can try to generalize some concepts in order to be able to apply them for different specific applications, and particularly to apply them for the proposed project application, that you must do in groups.

In the previous activities of this sesion, you must do the following:

  1. Read the material about data modeling and decissions of data structures in an application.

  2. For the application example of the resource you should have read (this application example has some analogies with the project that the groups must do), complete the following tasks:

    1. Define the data structures that are needed to store the information about the photos and authors using static memory with a fixed array of N elements for the photos and of M elements for the authors. How would you select the number N? Would you be always using the least amount of possible memory for the storage? What will be the maximum number of photos that you could have?

    2. Define the data structures that are needed to store the information about the photos in dynamic memory (all continous), and also the authors in other dynamic memory portion (all continous). You must not allocate more memory than necessary in any case. This is, you must not allocate memory for elements that are not going to be stored yet.

    3. Define the data structures that are needed to store the information about the photos in a linked list, and about the authors in another linked list.

    4. Define the data structures that are needed to store the information of all the photos in different linked lists, using a hash function to decide in which one of the linked list, the photo should be stored. You must also do it for the authors in an analogous way.

    5. For each one of the previous defined data structures, implement a function that will be able to initialize such data structures, representing that there is no element in that moment

    6. For each one of the previous defined data structures, implement a function that will be able to add a new photo to the collection. You can assume that there is not previously in the collection the specific photo that is going to be added. It must work both: for the case when there are not any photos in the collection, or when there are already some elements in the data structure.

Automatic self-assessment

Check with these questions if you understood the document on data struture modeling

  1. In an application, there is data about hotel companies, as well as their respective hotels. Each hotel can only belong to a hotel company. If in the design phase, we identify a table for the hotel companies, and another table for the hotels. Which will be the relationship between both tables?

    • 1:N. Each hotel has several hotel companies

    • N:1. Each hotel company has several hotels

    • Each hotel has several hotel companies, and each hotel company has several hotels

    • There are not any relationships between both tables

  2. Suppose that you need to use dynamic memory for storing several hotels that are registered in the application in a moment. In addition, you need to make quick searches of such hotels taking into account some of their information fields in order to select hotels according to certain restrictions. This number of hotels for searching can be from 1 to more than 1 million. The structure that suits better to store the information is:

    • Static array

    • Dynamic array

    • Linked list

    • Hash table with linked lists

  3. Consider that all the information about hotels and hotel companies must be stored in a file. If later we want to make frequently searching operations of hotels given a specific city where the hotel is located. For doing this type of operation, the better option is to store the information in a file that:

    • The information of each city is given one by one in a consecutive way, including as part of a city information, all the hotels of such city

    • The information of each hotel is given one by one in a consecutive way, including as part of a hotel information, the hotel company of such hotel

    • The information of each hotel company is given one by one in a consecutive way, including as part of a hotel company information, all the hotels of such hotel company

    • The information of each hotel category (number of stars) is given one by one in a consecutive way, including as part of a hotel category information, all the hotels of such category

  4. In a textual mode application, if we want to transform it in order to add a graphical interface for such application. The extension will be easier if:

    • We have developed all the application in a single file

    • We have divided the application in 3 well differenciated modules: data, control, and presentation

    • We have used linked lists for its development

    • We have compiled with the option -file in order to simplify this operation in a future