What am I doing wrong? I need to create the foreign key but the code begining at CONSTRAINT is wrong somehow, also I need help with my view I think im doing the subquery wrong can you help me?
CREATE TABLE dealer(
dealershipId CHAR(10),
phone CHAR(10),
dealershipName CHAR(10),
webAddress char (10),
street CHAR (10),
city char (10),
zip char (5),
mCapacity INT,
managerFName CHAR (10),
managerLName CHAR (10),
PRIMARY KEY (dealershipId));
CREATE TABLE automobiles(
autoId CHAR (4),
vehiclecode VARCHAR (15),
manufacturer VARCHAR(15),
model VARCHAR (20),
style VARCHAR (5),
color VARCHAR (10),
ownership VARCHAR (8),
PRIMARY KEY (autoId)
CONSTRAINT fkHasRep FOREIGN KEY (dealershipId)
REFERENCE dealer(dealershipId) ON DELETE RESTRICT
);
--7.
CREATE VIEW division AS
SELECT dealershipName, webAddress, phone
FROM dealer
WHERE dealershipId IN
( SELECT manufacturer, model, style, ownership
FROM automobiles);
--8.
SELECT phone, manufacturer, model
FROM division;