Jump to content

Help with creating table in database and how to program it


argrafic

Recommended Posts

Well, I'm about to start a new project and I face with something I had never faced before.

 

It's a form to input some data that will be registered about projects.

 

The issue here is in the image i post:

tabla.jpg

 

I'm really lost, I don't know how to do it so it stores all the data.

 

I was thinking of making a table for each column and all will be identified with the main id of the project, but i don't know if that's the best way to do it.

 

Thanks!!!

You only need another table where there can be multiple values, such as alarma and notas

 

[pre]

Phase                                            Task

==========                                        ===============

PhaseID    ------------------------------------<  PhaseID

Phase                                    +-----  TaskID    -------+

Duracion Est                              |      Task              |

Inicio                                    |                        |

Final                                    |                        |

Duracion Real                            |                        |

                                          |                        |

                      Alarma            |                        |          Notas

                      =============      |                        |          ==========

                      alarmaID          |                        |          notasID

                      TaskID  >---------+                        +-------<  TaskID

                      alarma                                                  notas

I noticed I forgot the task responsible column.

[pre]

Phase                                            Task

==========                                        ===============

PhaseID    ------------------------------------<  PhaseID

Phase                                    +-----  TaskID    -------+

Duracion Est                              |      Task              |

Inicio                                    |      Resp              |

Final                                    |                        |

Duracion_Real                            |                        |

                                          |                        |

                      Alarma            |                        |          Notas

                      =============      |                        |          ==========

                      alarmaID          |                        |          notasID

                      TaskID  >---------+                        +-------<  TaskID

                      alarma                                                  notas

[/pre]

SELECT p.Phase, p.Duracion Est, p.Inicio, p.Final, p.Duracion_Real,
t.Task, t.resp, GROUP_CONCAT(a.alarma) as alarms, 
GROUP_CONCAT(n.notes SEPARATOR '<br>') as notes
FROM Task AS t
    INNER JOIN phase AS p  ON t.PhaseID = p.PhaseID
    INNER JOIN alarma AS a ON t.TaskID = a.TaskID
    INNER JOIN notas AS n ON t.TaskID = n.TaskID
GROUP BY t.TaskID
ORDER BY t.PhasID, t.TaskID

 

Loop through result with a while loop. Output Phase when a new phase starts.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.