table with multiple possible one-to-many relation, but not many-to-many

I have an image table which looks like this, it has many possible one-to-many relationships, ie. room, profile and feedback can have many images.
export const image = pgTable('image', {
  id: guid('id').defaultRandom().notNull(),
  imageUrl: varchar('image_url', { length: 255 }).notNull(),

  roomId: uuid('room_id').references(() => room.id, {
    onDelete: 'cascade',
  }),
  profileId: uuid('profile_id').references(() => profile.id, {
    onDelete: 'cascade',
  }),
  feedbackId: uuid('feedback_id').references(() => feedback.id, {
    onDelete: 'cascade',
  }),
});

The issue is, I want the image to have only one relation at a time. So I don't want it to be possible for image to have both roomId and feedbackId as not null.

Want to know if this is possible. Also is there a better way to do images? How would you do tables for a relation like this?
Was this page helpful?