Basic database design : list of instances of type -
this beginners question database design. suppose have blogging website many users, each of whom have few blog posts. want find articles written given user. search post table blog posts given userid. design user table have list of user's posts. mean, perhaps, storing string of comma separated post ids. proper way this?
you're looking database normalization, technique prevents:
- redundancy (storing same data more once)
- anomalies (changing 1 datum changes another)
- cycles (changing changes b changes c changes a)
- redesign (adding or removing field requires changing other fields)
- bias (different ways of asking same question gives different answers)
the typical form of normalization called boyce-codd normal form , is, in general, quite difficult do, can improve design implementing lower normal forms.
you have not given enough information recommend schema you, “storing string of comma separated post ids” wrong thing if need distinguish between post ids. if that’s want should consider design like:
users userid other user fields .. 100 charlie 101 edith articles articleid userid pathorwhatever... 1000 100 http://example.com/stuff 1001 100 http://example.com/morestuff 1002 101 http://example.com/somethingelse this design can articles users, or users articles, database commands.
Comments
Post a Comment