• I apologize for the wrong format anyway I did my best to make my question clear. Pls refer to the items below:

    -- START

    USE student

    -- Create table for food category

    CREATE TABLE FoodCategory

    (

    Category nvarchar(50) PRIMARY KEY NOT NULL

    )

    -- Create table for food name and its category

    CREATE TABLE Food

    (

    [Name] nvarchar(50) PRIMARY KEY Not null,

    Category nvarchar(50) DEFAULT 'Unassigned' NOT NULL CONSTRAINT Food_Category_FK REFERENCES FoodCategory(Category) ON DELETE SET DEFAULT

    )

    -- Add values to foodcategory

    INSERT INTO FoodCategory VALUES('Fruits')

    INSERT INTO FoodCategory VALUES('Vegetables')

    -- Add values to Food

    INSERT INTO Food VALUES ('Apple','Fruits')

    INSERT INTO Food VALUES ('Spinach', 'Vegetables')

    -- Delete 'Fruits' category to test if the default value will be assigned when ON DELETE SET DEFAULT is the settings.

    DELETE FROM FoodCategory WHERE Category = 'Fruits'

    -- END

    After I perform the delete SQL Management studio gives me this message:

    Msg 547, Level 16, State 0, Line 1

    The DELETE statement conflicted with the FOREIGN KEY constraint "Food_Category_FK". The conflict occurred in database "Student", table "dbo.FoodCategory", column 'Category'.

    The statement has been terminated.

    Ive tried doing this with integer,it seems to work but what I need is a string value. I hope this makes my question clear. Thank You.