We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16348
    • 64 Posts
    Hi

    I’m developing an entry-/results-system for running competitions. I have the system up and running for one competition but now I want to scale it up to handle several competitions.

    All competitions have the same DB schema.

    My first approach was to have one DB table for each competition and then another one to keep record of them all. In the last table, i planned to store the table names for the different tables.
    My second approach was to only use one table and then add a field with an identifier for the competition.

    Which way is best to go or is there another way of doing this?

    If i choose the first approach, do I have to create one class/model for each table or can I use one and then point to different tables? I couldn’t find a xPDO-method for that.
    Will the second way impact in performance if I have many records? Say that I will end up with 20 competitions with 2000 entries in each one of them (=40 000 records)? It will for sure impact on my ability to survey and manage the differnet competitions.

    Best regards
    Kristoffer
      • 22873
      • 9 Posts
      I am not sure, if I fully understand the problem, but IMHO the standard approach is to have (at least) two tables - the first table for competitions (data for each competition would occupy one record (line) in the table).

      All the results data should be in another table (each result in a single record). Each record should contain an attribute competition_id (or so), which contains the ID of the related competition from the competition table.

      Then you will be able to obtain an object for a particular competion (e.g. via newQuery or getObject methods) and the results for that competition via getMany method. Or, alternatively you can obtain the particular results directly using join or getCollectionGraph methods.

      In general, the database schema should be relatively stable. It is rarely a good idea to have to add a table, if you need have a data record.
        • 24068
        • 4 Posts
        Quote from: Kristoffer at May 30, 2011, 09:20 AM

        Will the second way impact in performance if I have many records?

        Shure it will. But the question is: Will you notice that impact?
        Can one call it an "impact" or does this only mean eg 30 milliseconds? Do that 30 milliseconds make any difference? They might, but do they?

        Handling 40.000 rows should be no problem. But it depends on how much latency you can afford.