Social web application database design: how can I improve this schema?

后端 未结 2 590
别那么骄傲
别那么骄傲 2021-01-30 19:05

Background

I am developing a social web app for poets and writers, allowing them to share their poetry, gather feedback, and communicate with other poets. I have very

2条回答
  •  遥遥无期
    2021-01-30 19:24

    I'm not clear what's going on with your User* tables - they're set up as if they're 1:1 but the diagram reflects 1-to-many (the crow's foot symbol).

    The ExternalAccounts and UserSettings could be normalised further (in which case they would then be 1-to-many!), which will give you a more maintainable design - you wouldn't need to add further columns to your schema for additional External Account or Notification Types (although this may be less scalable in terms of performance).

    For example:

    ExternalAccounts
        UserId int,
        AccountType varchar(45),  
        AccountIdentifier varchar(45)
    

    will allow you to store LinkedIn, Google, etc. accounts in the same structure. Similarly, further Notification Types can be readily added using a structure like:

    UserSettings
        UserId int,  
        NotificationType varchar(45),  
        NotificationFlag ENUM('on','off')
    

    hth

提交回复
热议问题