This is very straight problem but I haven't figured out any solution yet. Scenario is I have 2 table in my DB. Source of 2nd table is dependent on 1st table's SOURCE_URL(can be more than 255 char so I have used TEXT).
create table SOURCES (
SOURCES_PK int not null AUTO_INCREMENT primary key,
SOURCE_URL text not null unique,
DESCRIPTION varchar(255)
);
create table ASSERTIONGROUP (
ASSERTION_PK int AUTO_INCREMENT primary key,
LABEL varchar(255),
SOURCE text not null,
foreign key (SOURCE) references SOURCES(SOURCE_URL)
);
I am getting this error-
BLOB/TEXT column 'SOURCE' used in key specification without a key length
I have seen discussion in this post - MySQL error: key specification without a key length.
But can't figure out any solution.
I can remove unique from 1st table but then I can't assign foreign key constraint.
I know that TEXT
field can't be unique so looking for an alternative.