How do I make multiple columns in one table refer to a foreign key in another table?

1

How do I make multiple columns in one table refer to a foreign key in another table? I want all columns called "SLOT", POSSAM to store a table key mods. NOTE: I'm using the latest version of NETBEANS I do not know if this makes any difference

create table "USE".UPGRADE
(
    U_ID INTEGER GENERATED ALWAYS AS IDENTITY not null,
    W_ID INTEGER,
    MODCAPACITY INTEGER,
    OROKINREACTOR BOOLEAN,
    LENS INTEGER,
    AURASLOT INTEGER,
    EXILUSSLOT INTEGER,
    POSTURESLOT INTEGER,
    SLOT1 INTEGER,
    SLOT2 INTEGER,
    SLOT3 INTEGER,
    SLOT4 INTEGER,
    SLOT5 INTEGER,
    SLOT6 INTEGER,
    SLOT7 INTEGER,
    SLOT8 INTEGER,
    SLOT9 INTEGER,
    SLOT10 INTEGER,
    primary key (U_ID),
    foreign key(W_ID) references WARFRAMES(W_ID)
);

create table "USE".MODS
(
    M_ID INTEGER GENERATED ALWAYS AS IDENTITY not null,
    U_ID INTEGER,
    NAME CHAR(30) not null unique,
    CAPACITYDRAIN INTEGER not null,
    POLARITY INTEGER not null,
    MODCOMPATIBILITY INTEGER not null,
    CONCLAVE INTEGER not null,
    QUANTITY INTEGER not null,
    RARITY INTEGER not null,
    MODLEVEL INTEGER not null,
    MODTYPE INTEGER not null,
    primary key(M_ID),
    foreign key(U_ID) references UPGRADE(U_ID)
);
    
asked by anonymous 01.03.2017 / 02:56

1 answer

0

The following is the command for columns 1 and 2 (the rest must follow the same logic):

alter table "USE".UPGRADE
add constraint SLOT1_FK FOREIGN KEY ( SLOT1 ) references "USE".MODS(M_ID);
alter table "USE".UPGRADE
add constraint SLOT2_FK FOREIGN KEY ( SLOT2 ) references "USE".MODS(M_ID);
    
01.03.2017 / 04:08