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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.