Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2009

    Question Foreign Key problem

    I am building a database and have hit a problem while assigning foreign keys.

    Assume I have a table for photo albums as follows:

    albums( aid integer,
    	name varchar(100),
    	description varchar(1000),
    	locationid integer,
    	type varchar(10),
    I also have tables for user, group, events (like facebook). Each of these tables has a PK (uid, gid, eid) which i want to use as a FK in the albums table in the attribute locationid where the attribute type is the name of the table. This lets me have an album for photos, users or groups. The problem is that I am unable to set locationid to be a FK to uid & pid & gid at the same time.

    If I don't set locationid as a FK then it all works, but that is bad design.
    Any advice on how the change my design?

  2. #2
    Join Date
    Apr 2009
    worked it out...
    i just need to add a column in user, group and events tables which is a FK to the aid of albums. then i can remove the location id

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts