Cannot insert duplicate key in object SQL Server [closed]

  Kiến thức lập trình

This error occurs in every table, every time I execute query it in my database.

First table

second tableto create the tables:

The source code used

CREATE DATABASE Personal24
GO
USE Personal24
GO
CREATE TABLE Department(
    id_dep tinyint identity PRIMARY KEY,
    name_dep varchar(25) UNIQUE NOT NULL
)
GO
CREATE TABLE Post(
    id_post tinyint IDENTITY PRIMARY KEY,
    Name_post varchar(30) NOT NULL UNIQUE,
    Post_money decimal (7,2) NOT NULL,
    Days tinyint NOT NULL,
    Count_post tinyint NOT NULL
)
GO
CREATE TABLE Persona(
    id_man smallint IDENTITY PRIMARY KEY,
    PassNo varchar(12) NOT NULL UNIQUE,
    Surname varchar(25) NOT NULL,
    Name1 varchar(12) NOT NULL,
    Birthdate smalldatetime NOT NULL,
    Sex char(1) NOT NULL,
    Education varchar(15),
    Married bit,
    Children tinyint
) 
GO
CREATE TABLE Worker(
    id_work smallint IDENTITY PRIMARY KEY,
    id_man smallint REFERENCES Persona not null,
    id_post tinyint REFERENCES Post,
    id_dep tinyint REFERENCES Department,
    main_work bit NOT NULL,
    stavka decimal (4,2) NOT NULL,
    date_work datetime,
    UNIQUE(id_man, main_work)
)
GO

New contributor

buchar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

6

LEAVE A COMMENT