I have created two tables: State and Store. The primary key for the State table is StoreStateID, which is an auto-incremented integer. The primary key for the Store table is StoreID, and it requires a foreign key that references StoreStateID. Even though I can successfully create the tables and import the data, I am having issues with the StoreStateID column, which always returns NULL. I'm not sure why the table is failing to reference the State table. Below is the code that I used to create the tables:
State Table:
sql
CREATE TABLE State (
StoreStateID INT NOT NULL AUTO_INCREMENT,
StateVPofSales VARCHAR(30),
PRIMARY KEY (StoreStateID)
);
Store Table:
sql
CREATE TABLE Store (
StoreID INT NOT NULL AUTO_INCREMENT,
StoreStateID INT NOT NULL,
PRIMARY KEY (StoreID),
FOREIGN KEY (StoreStateID) REFERENCES State(StoreStateID)
);
I would appreciate any insights
koows developerbook echat into why this issue is occurring.