1

Topic: How to express it ?

There is such table
id, fk, DateStart, Name, GroupId
1, 1, 1/1/2010 10.30, "Test1", 1
2, 1, 1/1/2010 12.30, "Test2", 1
3, 2, 1/1/2010 15.30, "Test1", 1
I.e. at FK=1 from 10.30 till there was name Test1. But from 15.30 this name has been given FK2.
It is necessary to provide, that in one time frame in one group there could not be some entities (fk) with an identical name. How it to provide?
The question is more difficult. Whether it is possible to provide it through Entity Framework?

2

Re: How to express it ?

TsHeloWorlder;
To write foolish function for foolish

3

Re: How to express it ?

TsHeloWorlder;
"Who on whom stood?" (c)

4

Re: How to express it ?

Entity Framework here what side? Same the client.

5

Re: How to express it ?

On the shown data we present that it is necessary to add two records where FK=3 at 13:30 receives name Test1, and at 14:30 changes it on Test3. In that order to add records it is impossible - described  does not allow to have name Test1 to two FK (2 and 3) after adding of the first record, but before adding of the second while upside-down records will be added without problems.
The output is simple - a designing error.

6

Re: How to express it ?

TsHeloWorlder;
Create unique index on fk, name, groupid.

7

Re: How to express it ?

Kolosov wrote:

TsHeloWorlder;
Create unique index on fk, name, groupid.

But then it does not allow to change a name in flow of day.

8

Re: How to express it ?

Akina wrote:

On the shown data we present that it is necessary to add two records where FK=3 at 13:30 receives name Test1, and at 14:30 changes it on Test3. In that order to add records it is impossible - described  does not allow to have name Test1 to two FK (2 and 3) after adding of the first record, but before adding of the second while upside-down records will be added without problems.
The output is simple - a designing error.

No, all is true. At attempt to add FK=3 with name Test1 the user sees an error "such name already is". Also understands that it is necessary to "release" name Test1 at first. If he does not know, what name Test1 will be released by the second insertion (for example other user) that it should have a question "as it at me will be 2 subjects with one name? Something not so, is necessary " then learns from colleagues that Test1 is planned to release and makes it, or waits when the colleague makes.
In general I do not see a problem. Users are not blunt, and understand that to what by these errors. For it and it is obvious that there can not be 2 subjects with an identical name in one interval of time. And the program protects them from silly errors which break account system - it from it will be worse, so that such protection for them and becomes.

9

Re: How to express it ?

Kolosov wrote:

Entity Framework here what side? Same the client.

Well so, if Code First the approach somehow it is necessary to push through this restriction in basis - through EF. That all has been saved in migrations and played back at other developers (in their local DB).

10

Re: How to express it ?

I such did in the trigger.

11

Re: How to express it ?

iap wrote:

I such did in the trigger.

I will support, if it is necessary business of the logician , instead of trigger

12

Re: How to express it ?

TsHeloWorlder wrote:

it is passed...
But then it does not allow to change a name in flow of day.

Why? The name enters. Uniqueness will not be broken.

13

Re: How to express it ?

TaPaK wrote:

I will support, if it is necessary business of the logician , instead of trigger

Only not instead of, and the normal trigger

14

Re: How to express it ?

dies irae wrote:

it is passed...
Only not instead of, and the normal trigger

to interpose, then to correct and roll away? Quit a class

15

Re: How to express it ?

TsHeloWorlder wrote:

Users are not blunt

Rather a popular belief.
I do not understand, why storage of date of the fact of change, instead of a range the beginning-end for value is used. For open date of end thus it is possible to use date in the far future (we tell, as much as possible admissible value) or special value (for example, Null). And the client part at interference detection can not only inform on it, but also specify, with what record intersection (it hardly will be easier, than in current structure), and even to fulfill on demand of the operator necessary adjustment (we tell, closing of interfering record with open date) automatically...

16

Re: How to express it ?

[quote =] I do not understand, why storage of date of the fact of change is used, instead of a range the beginning-end for value

closing Date is necessary only in a case when the essence can have the period  (the old period ended, new did not come yet). In other cases enough one date.