1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Database architecture

Discussion in 'MySQL' started by Jack20, Mar 17, 2020.

  1. #1
    I was looking at how Elgg stored data and it made start wondering.

    Usually when your site has posts, comments, etc you would have tables something like (posts, comments), but everything here is stored in two tables.

    The two tables are: `entities` and `metadata` and they are structured as so:

    Entities:
    ```
    ------------------------------------------------------------
    | Name | Type |
    ------------------------------------------------------------
    | guid | int(20) |
    | type | enum('object', 'user', 'group', 'site') |
    | subtype | varchar(252) |
    | owner_guid | int(20) |
    | container_guid | int(20) |
    | access_id | int(11) |
    | time_created | int(11) |
    | time_updated | int(11) |
    | last_action | int(11) |
    | enabled | enum('yes', 'no') |
    ------------------------------------------------------------
    ```
    and the metadata structure is
    ```
    ----------------------------------------------
    | Name | Type |
    ----------------------------------------------
    | id | int(11) |
    | entity_guid | int(20) |
    | name | text |
    | value | longtext |
    | value_type | enum('integer', 'text') |
    | owner_guid | int(11) |
    | access_id | int(11) |
    | time_created | int(11) |
    | enabled | enum('yes', 'no') |
    ----------------------------------------------
    ```

    If properly indexed, is this better at scale too? What are the benefits and drawbacks to this method?
     
    Jack20, Mar 17, 2020 IP