I need to create two tables in relationship one to many. I have created following statements. Maven gives me an error about "unique constraint". I don't know how to fix it, someone can explain me how to create correct relationship in this example?
CREATE TABLE Owner(
owner_id INT GENERATED BY DEFAULT AS IDENTITY,
firstname varchar(20),
lastname varchar(20)
)
"CREATE TABLE Picture(
picture_id INT GENERATED BY DEFAULT AS IDENTITY,
owner_id INT, name varchar(20),
width INT, height INT,
FOREIGN KEY(pic_owner_id) REFERENCES Owner(owner_id)
)
You need to add a primary key.
CREATE TABLE Owner( owner_id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, firstname varchar(20), lastname varchar(20) )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.