1

Topic: Error: misses primary keys banishing on the exterior. How it is possible to correct?

2

Re: Error: misses primary keys banishing on the exterior. How it is possible to correct?

belu4ano-kg;
  perception of the Nayward of Force. Holokrony of the Nayward help to recover balance of Force, young . Foreign keys bring the world, rest and justice in the Galaxy.

3

Re: Error: misses primary keys banishing on the exterior. How it is possible to correct?

belu4ano-kg wrote:

an error: misses primary keys banishing on the exterior. How it is possible to correct?

to Correct it is possible including an adequacy mode: to give an executable script (instead of any left screenshot) and authentic, instead of composed or retold, the error text.

4

Re: Error: misses primary keys banishing on the exterior. How it is possible to correct?

Gavrilenko Sergey Alekseevich;
[spoiler]

create database test
go
use [ts2]
go
--4 -
create table education
(id_education int not null primary key;
level_of_education varchar (500) not null;
qualification_improvement varchar (500) not null;
specialization varchar (500) not null;
)
--3.1 -
create table Surcharge
(id_surcharge int not null primary key;
name_surcharge varchar (500) not null;
amount_surcharge varchar (500) not null;
) ;
--3 -
create table salary (
id_salary int not null primary key;
id_surcharge int not null foreign key references Surcharge (id_surcharge);
id_position int not null foreign key references Position (id_position),
id_employee int not null foreign key references personal_information (id_employee),
number_card int not null;
secondment int not null;
vacation int not null;
grace int not null;
bonus int not null;
amendment_to_act varchar (100) not null;
);
--2.3 -
create table vacancy
(id_vacancy int not null primary key;
Duties varchar (500) not null;
requirements varchar (500) not null;
open_position varchar (500) not null;
)
--2.2.1 -
create table work_expirience
(
id_work_experience int not null primary key;
seniority int not null,
general_expirience int not null
)
--2.2 -
create table working_activity
(id_work_activity int not null primary key;
number_decree varchar (500) not null;
id_work_experience int not null foreign key references work_expirience (id_work_experience);
date_of_admission date not null;
date_of_dismissal date not null;
promotion varchar (500) not null;
)
--2.1 -
create table position
(id_position int not null primary key;
id_salary int not null foreign key references salary (id_salary);
position_name varchar (500) not null;
)
--2 -
create table department
(id_department INT NOT NULL primary key;
id_position int not null foreign key references position (id_position),
id_work_activity int not null foreign key references working_activity (id_work_activity);
id_vacancy int not null foreign key references vacancy (id_vacancy);
department_name varchar (500) not null;
department_phone varchar (500) not null;
department_head varchar (500) not null;
)
create table employee
(id_employee INT NOT NULL primary key,
id_department INT NOT NULL foreign key references department (id_department);
id_salary int not null foreign key references salary (id_salary);
id_education INT NOT NULL foreign key references education (id_education);
) ;
--1 -
create table personal_information
(id_employee int not null foreign key references employee (id_employee);
id_presence_of_children int not null Primary key;
Surname varchar (500) not null;
Name varchar (500) not null;
Patronymic varchar (100) not null;
Age date not null;
Home_address varchar (500) not null;
Phone_number int not null;
marital_status varchar (500) not null;
passport_data varchar (500) not null;
education varchar (500) not null;
citizenship varchar (500) not null;
gender varchar (500) not null;
)
--1.1 -
create table presence_of_children
(id_presence_of_children int not null foreign key references personal_information (id_presence_of_children),
amount_of_adult int not null;
number_of_minor_child int not null;
total_quantity int not null;
)

[/spoiler]

5

Re: Error: misses primary keys banishing on the exterior. How it is possible to correct?

create database test go use [ts2] go

You at first try to create basis test, then switch a context to basis ts2 and start something to do in it.
You are assured, what it and is necessary for you?
Where the original of the text of an error?

6

Re: Error: misses primary keys banishing on the exterior. How it is possible to correct?

belu4ano-kg;
Save-paste harm.

-- Compare
create table work_expirience
(
id_work_experience int not null primary key;
seniority int not null,
general_expirience int not null
)
-- And
create table work_expirience
(
d_work_experience int not null foreign key references work_expirience (id_work_experience);
seniority int not null,
general_expirience int not null
)

7

Re: Error: misses primary keys banishing on the exterior. How it is possible to correct?

belu4ano-kg wrote:

create database test
go
use [ts2]
go

Anything, what you create one basis, and pass for performance of scripts in another?

8

Re: Error: misses primary keys banishing on the exterior. How it is possible to correct?

Slice;
The message 1767, level 16, state 0, line 27
The foreign key "FK __ salary __ id_posit __ 15502E78" refers to the inadmissible table "Position"

9

Re: Error: misses primary keys banishing on the exterior. How it is possible to correct?

belu4ano-kg wrote:

the Slice;
The message 1767, level 16, state 0, line 27
The foreign key "FK __ salary __ id_posit __ 15502E78" refers to the inadmissible table "Position"

you it surprises?
You create the table salary with table reference Position, and table Position during this moment still is not present, it in a script forms later.
Simply read error messages, there  all is written by simple English language.
I do not speak about different registers - Position and position, ugly, and can lead to errors.

10

Re: Error: misses primary keys banishing on the exterior. How it is possible to correct?

Minamoto;
Badly .
It is changed

11

Re: Error: misses primary keys banishing on the exterior. How it is possible to correct?

alexeyvg wrote:

it is passed...
It surprises you?
You create the table salary with table reference Position, and table Position during this moment still is not present, it in a script forms later.
Simply read error messages, there  all is written by simple English language.
I do not speak about different registers - Position and position, ugly, and can lead to errors.

That Mahlo, Position still in itself refers on Salary, i.e. we here see cyclical foreign keys.
, a problem in badly designed basis, it is necessary to alter structure, instead of to prompt, as such to fulfill. If very much it would be desirable - it is necessary to carry out the code of creation of foreign keys in separate requests, and to create them after both tables exist. The code for creation of an exterior key:

alter table dbo.working_activity add constraint FK_working_activity foreign key (id_work_experience) references dbo.work_expirience (id_work_experience);

12

Re: Error: misses primary keys banishing on the exterior. How it is possible to correct?

Minamoto;
Nevertheless thanks for the help.

13

Re: Error: misses primary keys banishing on the exterior. How it is possible to correct?

belu4ano-kg;
The author does not understand that such a key and foreign key... To Learn a subject to an enlightenment.

14

Re: Error: misses primary keys banishing on the exterior. How it is possible to correct?

Minamoto wrote:

that Mahlo, Position still in itself refers on Salary, i.e. we here see cyclical foreign keys

In what "recurrence" consists?
And in what a crime shown FOREIGN KEY in Position and Salary?
If there to register the cascade removals, for example, that yes, the server most likely will be abused and does not resolve.
And so - what to it business to any "recurrence"! If only  it was fulfilled.
Another matter that referring fields in both are declared NOT NULL.
Because of it to interpose records into these tables never it turns out.

15

Re: Error: misses primary keys banishing on the exterior. How it is possible to correct?

iap wrote:

it is passed...
In what "recurrence" consists?
And in what a crime shown FOREIGN KEY in Position and Salary?
If there to register the cascade removals, for example, that yes, the server most likely will be abused and does not resolve.
And so - what to it business to any "recurrence"! If only  it was fulfilled.
Another matter that referring fields in both are declared NOT NULL.
Because of it to interpose records into these tables never it turns out.

Recurrence just in "Position refers on Salary, and Salary on Position"
Nobody says that it is inadmissible, but, in the first, it is necessary to do at least one field NOT NULL, in the second, to create  separately.
Well and I would look at model and business logic for which it is created.
Circular references though are possible, but should cause suspicions, so to say, the occasion to stop and think, in it Minamoto is absolutely right.

16

Re: Error: misses primary keys banishing on the exterior. How it is possible to correct?

iap;
Broad gull th model it is constructed that on position could refer the table surcharge and vacancy

17

Re: Error: misses primary keys banishing on the exterior. How it is possible to correct?

belu4ano-kg;
On ideas * but as the result shows that is necessary finishings

18

Re: Error: misses primary keys banishing on the exterior. How it is possible to correct?

Andy_OLAP wrote:

belu4ano-kg;
  perception of the Nayward of Force. Holokrony of the Nayward help to recover balance of Force, young . Foreign keys bring the world, rest and justice in the Galaxy.

Only the real master  from blessing of the master develops bases without foreign keys. For in such bases speed and power of dark force is covered.