MySQL Forums
Forum List  »  Newbie

Re: Problem setting foreign key
Posted by: Peter Brawley
Date: September 10, 2017 06:57PM

Presumably one business can make many deals, in which case the FK declaration should be in deals not businesses ...

drop table if exists deals,businesses;

CREATE TABLE IF NOT EXISTS businesses ( 
  businesses_id VARCHAR(40) PRIMARY KEY, 
  ...
);

CREATE TABLE IF NOT EXISTS deals( 
  deals_id VARCHAR(40) PRIMARY KEY, 
  businesses_id VARCHAR(40), 
  ...
  FOREIGN KEY (businesses_id) REFERENCES businesses(businesses_id) 
);



Edited 1 time(s). Last edit at 09/11/2017 02:13PM by Peter Brawley.

Options: ReplyQuote


Subject
Written By
Posted
September 10, 2017 01:02PM
Re: Problem setting foreign key
September 10, 2017 06:57PM
September 11, 2017 11:58AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.