I apologize for my lack of knowledge or incorrect usage of terms; I am taking an online DBMS course and it is mostly self-taught with Microsoft SQL Server.
We are tasked with creating a database design and inserting data into it for something that interests us. I chose to create a database based on Dungeons and Dragons, and had a question on if I was doing something correctly.
I intend to create a Spell_Source table that will hold the primary key of multiple different tables (Class and Subclass) as one column, and the name of the spell (a primary key in a different table) as the other. When I go to input the data however, the foreign key constraints are stopping the insertion.
I am fully prepared to redesign the database itself if it's a problem in normalization, or if there's a simple fix that I'm missing due the self-taught nature of the class.
Thanks for your help!
CREATE TABLE SPELL_SOURCE (
SpellName VarChar(50) NOT NULL,
SpellSource Char(25) NOT NULL,
CONSTRAINT SpellSourcePK1 PRIMARY KEY (SpellName, SpellSource),
CONSTRAINT SpellSourceFK FOREIGN KEY (SpellName)
REFERENCES SPELLS(SpellName)
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT SpellSourceFK1 FOREIGN KEY (SpellSource)
REFERENCES CLASS(ClassName)
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT SpellSourceFK2 FOREIGN KEY (SpellSource)
REFERENCES SUBCLASS(SubclassName)
ON UPDATE NO ACTION
ON DELETE NO ACTION
);
The exact error I'm getting from the Import Data tool is "The INSERT statement conflicted with the FOREIGN KEY constraint "SpellSourceFK1". The conflict occured in database table "dbo.CLASS", "ClassName""