Suggest improvements for the database design

試著忘記壹切 提交于 2020-01-06 12:42:20

问题


Design :-

1)A story board has a number of slides, each slide can have one or more captions or images.

2)Each storyboard can have one or more author , and zero or more reviewers.

3) Each of the objects image,slide and caption(probably more objects will come later like audio etc) can have comments on them . These comments can be given by authors or reviewers. For storing comments I have created a comment table.

4)It is necessary to remember the order of slides and order of images in a slide , for which I am using slide and image number fields.

5)Since comment can be given on any object , I needed to have a Global ID for each of the object,since their reference will be stored in a comment table.For maintaining a global id all the fields ending with name GID are uniqueidentifiers generated using Default: NEWID().

6)Users are stored in user table.

7)User should be able to view and load only the storyboards in which he is a author,reviewer or owner.

Please suggest improvements for this db design.


回答1:


i see that not all your tables have a PK, actually i only see that the user table has one, and the storyboard is using the name and owner as PK?

i prefer to use an id to all my tables, except the intermediary tables used for NxN relation, like you did on the authors and reviewers. You did the same but you called it GID. I'd use them as PK (and auto incremental also).

Don't worry if an object has the same GID as another object on a different table, because in your comments table you have an ObjType that specifies the table related to the object. So it will be ok if a User's GID is the same as the StoryBoard's GID.

I'm not used to the sql-server diagrams, but it seems that the relations are not well defined: i see that user and storyboard are related in a 1xN but it looks like the storyboard and the slides are related in a 1x1 relation, when it should also be a 1xN

A storyboard has a owner and different authors, that means that if i create a storyboard, the storyboard will have my id in the OwnersUserId and my id will also be stored in the authors table? if yes, it seems unnecessary. Or.. well.. it depends on the conception of your model. I see two options:

  • a StoryBoard has ONE author and ONE OR MANY collaborators

    (dont change your model, only rename the authors table to collaborators or something more precise)

  • a StoryBoard has ONE OR MORE authors and one of them is the owner

    (remove the 1xN relation between Users and storyboard and add a type columm to the Authors table)

A final observation:

User should be able to view and load only the storyboards created by him.

it wont change the data model.. =) but, if only the authors can view the storyboards, then who will review them?

My observations are just superficial, I find the model well adjusted to the problem

Good Luck



来源:https://stackoverflow.com/questions/5660583/suggest-improvements-for-the-database-design

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!