Jump to content

Best way to organise my stored data?


razta

Recommended Posts

Hello!

 

I am building a web application and I'm not sure what the most efficient way of storing my data is. I have some experience with SQL however it seems obviously not enough.

 

My table looks as follows:

SELECT * FROM data;

+----------+---------------------------+----------+------------------+------------------+
|      id        |             name                    |    tree     |    old_versions     |  latest_version    |
+----------+---------------------------+----------+------------------+------------------+
|      1        |             MYSQL                  |     CS      |   1,1.1,1.2,1.3    |          1.5             |
|      2        |               PHP                     |     5.3     |    5.3.1,5.3.2      |         5.3.3           |
|      3        |               PHP                     |     5.2     |    5.2.1, 5.2.2     |         5.2.3           |
|      4        |               ASP                    |                |                            |                             |
+----------+---------------------------+----------+------------------+------------------+

 

Now what I want to do is add the release date to the 'old versions' and 'latest_version'. What's the best way to structure my database to do this?

 

The data being output would be something like:

 

LATEST: PHP 5.3 (released: 01/01/2010)

              PHP 5.3.1 (released: 01/01/2009) 

              PHP 5.3.0 (released: 01/01/2008)

 

Any help is much appreciated.

 

Thank you.

Link to comment
https://forums.phpfreaks.com/topic/200916-best-way-to-organise-my-stored-data/
Share on other sites

I would create a second table to store the release dates

 

Columns would be

Autonumber, ID, version, date

 

So your tables might look something like this

 

SELECT * FROM data;

 

+---+-----------+------+

|ID |    name  | tree |

+---+-----------+------+

| 1 |  MYSQL  |  CS  |

| 2 |    PHP    |  5.3 |

| 3 |    PHP    |  5.2 |

| 4 |    ASP    |      |

+---+-----------+------+

 

SELECT * FROM versions;

 

+----------+----+---------+----------+

|autonumber| ID | Version |  Date  |

+----------+----+---------+----------+

|    1    |  1 |    1  |          |

|    2    |  1 |  1.1  |          |

|    3    |  1 |  1.2  |          |

|    4    |  1 |  1.3  |          |

|    5    |  2 |  5.3.1  |          |

|    6    |  2 |  5.3.2  |          |

|    7    |  3 |  5.2.1  |          |

|    8    |  3 |  5.2.2  |          |

|    9    |  4 |        |          |

+----------+----+---------+----------+

 

Then simply relate the ID fields of the two tables, this would allow for infinate new versions to be introduced and recorded without any messy parsing being required, as per your 'old_versions' field.

 

Hope this helps,

If I can be of any more assistance please ask

 

Daz

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.