Is it okay to have one table for storing images against multiple tables - SQL Server 2008 R2 -
Is there a table to store images against multiple tables? Or is it better for three different tables? There may only be two images in the office.
Schema
-
Inspector
- InspectorX (PK), Inspector's Name -
Office
- OfficeID (PK), OfficeName -
Employee
- StaffID (PK), Staff name
New Photos
table (collecting images in binary form for different tables)
Photos - Photo ID (PK) , PhotoData, InspectorAD (FK), OfficeID (FK), Staff ID (FK)
New Schema
-
Inspector - Inspectorector (PK), Inspector's Name, Photo ID (FK) or
Photo IDI (FK) , Photo IDO (FK) -
Office
- OfficeID (PK), OfficeName, Photo ID (FK) Code> - Staff ID (PK), StaffName, Photo ID (FK)
this is ok But you do not need FK in both the photo table and the other tables. Just put the PhotoID FK in the other three tables.
If you are worried about the second picture only for the offices, then a second photographed in the office table It's OK to add an FK
If you want another scalable solution, and / or if more than one of the pictures can be used for more than one photo, then there may be a sequence.
Or if a picture can be related to only one unit, then you have one-to-many in the opposite direction, and you can put the FK column in the photo table, and you can add them to other entities. You can add an "Order" column to the photo table to remove the order from the table so that the ordering order for the photo can be specified in the photo, or any further information that can use that information.
Comments
Post a Comment