It depends on how photos and videos are structured. Consider the following database project:
MediaType ---------- ID * Name Media ---------- ID * TypeID OwnerName Name Size Path Photo ---------- MediaID * MediaTypeID (constraint, always set to the photo type) Height Width Video --------- MediaID * MediaTypeID (constraint, always set to the video type) Rating
If the photos and videos had FK on MediaType and on Media, I would make comments related to the Media table, and not to one, and not to the photo table or video directly. This is often the type of design that I use when Photo and Video have many common properties. This is especially useful when you want to do something like security, because you do not insert into yourself a repetition of the same constructions of visibility and ownership on each type of media with which you deal. It also queries quite quickly, because many queries often look only at common properties or just at type strings, so some tables do not need to be included. Designing a database by modeling these IS-A relationships also makes your indexes top-secret, which means speed.
If you are locked in your design, and videos and photos do not have a commmon “base table”, then I would create a separate comment table for each.
source share