0

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?

Rohit
  • 81
  • 7

2 Answers2

0

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.

Skilldrick
  • 69,215
  • 34
  • 177
  • 229
  • But i still need to store the current privacy levels in the tables i assume like Album = friends only and store a user privacy level for the photos also? – Rohit Feb 08 '11 at 22:35
  • Yeah, albums and photos have a privacy level - if the album privacy level is set then use that, otherwise use the photo privacy level. – Skilldrick Feb 08 '11 at 22:40
  • Ok Let me map this out with my privacy levels and see how it works. – Rohit Feb 08 '11 at 23:00
0

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.

Val Schuman
  • 1,798
  • 2
  • 18
  • 23
  • Well this ok for a site like facebook where privacy is structured. I have unstructured privacy like you can allow "friends of a friend" but block your friends. Or allow only networks and friends of a friend but block your friends. So there is a mix of structured and unstructured privacy + there are block lists too. – Rohit Feb 08 '11 at 23:00