Fork me on GitHub

Happy Pi-day people


Another question on the SQL-theme now that I have decided to go with Postgres: I understand that I can replace one-to-many relations that in MySQL has to be done with one child table pointing to a parent table with Postgres arrays. Does anyone have thoughts on when either approach should be used?


@vikeri: You mean you want to store table data in an array that belongs to the "parent" table? I am just asking, never heard of this feature before


@sveri: Imagine you have a table containing users and then each user has some pets, do you put a list of those pets in an array in the user table or do you create a separate table called pets where each pet is linked back to a user through the column user_id


@vikeri: Hm, If I have a given set of pets I guess I would put them into a different table, especially if the pets have additional attributes like age, color, whatever. If I want to store only pet names, an array seems useful.


Yea, I guess the attributes thing is what it comes down to.


@vikeri: Also I would wonder how the performance characteristics are in this case. What if I search for every user having a relation to pet X. Can I put indices on the arrays?


While talking about databases, I just found about how reddit scaled there database: Lesson 3. Sounds interesting, almost like a key-key-value store. Anyone ever tried that?