New answers tagged constraint
I guess that you mean: "every Nurse is an Employee". This can be done with (keeping the Employee table as it is): CREATE TABLE [dbo].[Employee]( [Id] [int] IDENTITY(1,1) NOT NULL, -- why not name this EmployeeId ? [Name] [nvarchar](100) NOT NULL, [StaffNumber] [nvarchar](50) NOT NULL, [Salary] [money] NOT NULL, [Address] ...
Seems all you need to do is to add a primary key to your Nurse table and add a uniqu foreign key relationship from the Nurse table to the Employee table; CREATE TABLE [dbo].[Employee]( [Id] [int] IDENTITY(1,1) NOT NULL, [Name] [nvarchar](100) NOT NULL, [StaffNumber] [nvarchar](50) NOT NULL, [Salary] [money] NOT NULL, [Address] ...
I ended up here with very same error, which was occuring rarely, and was hard to track, because I was loking for it not where I should. Fault was JS repetition which was doing the POST to the server twice! So sometimes it is worth to have a look not only on your django (or any other web framework) views and forms but also what happens on very front side.
Because the value is incremented outside the scope of the transaction. This is the way you want it to work, so that separate transactions can happily insert rows or roll back without waiting for each other. If you care about gaps or want different behavior, stop using the built in and roll your own...
Top 50 recent answers are included