I am trying to make two database table and linked them together. Here is my code:
CREATE TABLE `NYSE_daily_prices_A` (
`StockSymbol` varchar(10) NOT NULL ,
`StockName` varchar(100) NOT NULL ,
`StockExchange` varchar(10) NOT NULL ,
PRIMARY KEY (
`StockSymbol`
)
);
CREATE TABLE `NYSE_stock_names` (
`StockExchange` varchar(10) NOT NULL ,
`StockSymbol` varchar(10) NOT NULL ,
`date` varchar(10) NOT NULL ,
`StockPriceOpen` money NOT NULL ,
`StockPriceHigh` money NOT NULL ,
`StockPriceLow` money NOT NULL ,
`StockPriceClose` money NOT NULL ,
`StockVolume` int NOT NULL ,
`StockPriceAdjClose` money NOT NULL
);
ALTER TABLE `NYSE_stock_names` ADD
CONSTRAINT `fk_NYSE_stock_names_StockSymbol`
FOREIGN KEY(`StockSymbol`)
REFERENCES `NYSE_daily_prices_A` (`StockSymbol`);
I tried to run this script in SQLiteStudio, it reports an error as following:
However, i copied the script into SQL Fiddle and it reports as following:
It really confuses me. How to fix this issue? Thanks in advance.