开发者

Parent - child relationship for album-photo privacy

开发者 https://www.devze.com 2023-02-09 15:05 出处:网络
How do we best represent a parent child relationship where the child has its own settings, the parent has its own开发者_如何学运维 but the parent can overwrite the child?

How do we best represent a parent child relationship where the child has its own settings, the parent has its own开发者_如何学运维 but the parent can overwrite the child?

My usecase is privacy level for photo album. Each album and each photo has a privacy level. So if album = custom then each photo can have different privacy level. But ofcourse if album is set to 'friends only' then the photos cannot be public, so any photo that is public is overwritten to private. Or if album is set to 'network only' then friends can see it but public cannot.

I am not sure if this is handled via application logic or through schema. If via application logic then do i need 'ANY' colunm in these tables for this or is it 100% application side?


You could have a permissions hierarchy, 0 - public, 1 - network, 2 - friends, 3 - self. Both albums and photos would have a permissions field in the database, but the permissions for photos always have to be >= permissions for the album they're in. By default they'd be equal to album permissions.

This way you could have a network-only album with some friends-only and some self-only photos.

Thus, the information about permissions for each object would be stored in the database, but the application would control which permissions can be set for photos and, of course, who gets to see what album/photo based on the permissions of the object and the status/position of the visitor.


I think this has to be in the application. It's not a lot of work, basically you check if the album has a privacy level, and if so apply that to its children, otherwise use the privacy level of the children. This isn't the sort of thing you'd handle in the db.

0

精彩评论

暂无评论...
验证码 换一张
取 消