Is this code allowed in MySQL language?

Thread Starter

Samantha Groves

Joined Nov 25, 2023
152
I have this code for MySql language:
Code:
create table representator
(
id int not null,
nameOrAddress text not null
primary key(id)
foreign key(nameOrAddress) references (county(name) union person(address))
)

create table county(
name text not null,


)

create table person(
address text not null,
primary key(address)
)
A representator can be either a county or a person.Is this MySql code valid (the foreign key part)?
 
Top