I apologize in advance for a lot of letters.

1. Input data

There are 2 tables:

// theme - тематика id | num | description // project - проекты id | description 

These two tables are related by the 3rd table, Many to Many.

By structure: The theme contains several Projects. For each project, you can find out the amount of hours spent, i.e. for the Theme to calculate the clock is also possible.

2. Problem solved by me

There was a need to create a template export, customizable (from php) to Excel. So the template should be stored, I chose a storage location - a table in the database. As a template, only the table header is implied.

3. Features of the template:

  • The column can be both Theme and Project
  • Topics and Projects can be grouped.

For example:

 Тема1 (Т1) - проект1 (п1) - проект2 (п2) Тема2 (Т2) - проект1 (п1) - проект3 (п3) Тема3 (Т3) - проект1 (п1) - проект4 (п4) 

This structure so that you can create such a pattern:

 Группировка1 | Т2 | Т3.п1 | Т3.п4 | Т1.п1 | Т1.п2 | | | | 

4. My ideas / start of design

Create a table, one row of which will contain either "Grouping", or "Topic" (link), or "Project" (link) and settings.

 id // id_theme // ссылка на тему id_project // ссылка на проект description // описание, название колонки parent // для темы и проекта - отношение к группировке order // порядок 

the combination of id_theme and id_project form the view - Grouping (both null), Subject (id_project = null), Project (both specified).

But with this structure, there are some difficulties with editing.

5. Question

  • In the right direction does he even bring me to the approach to this problem?
  • Is there a better (in structure / performance / simplicity) approach?

    0