New answers tagged

6

You are right, the design allows inconsistencies, exactly what you notice. A ProjectRealm may be referring through Project to a company and through CompanyRealm to another company. This is not uncommon, it appears when there is a triangular or a "diamond" shape in the relationships: Realm Company \ / \ \ / \ ...


7

SQL Server doesn't randomly set integers to -2147483648. In any event it is clear that you have a constraint that should be being checked, negative prices are not good. First clean up the rows with invalid values then you can add a check constraint ALTER TABLE YourTable ADD CONSTRAINT CK_CheckPriceInRange CHECK(Price BETWEEN 0 AND 999999); Now any ...


5

And I want to limit the number of referees on a single match to three, How can i do that? One method is with a trigger: CREATE TRIGGER tr_match_referee ON dbo.match_referee FOR INSERT, UPDATE AS IF EXISTS( SELECT 1 FROM inserted JOIN dbo.match_referee WITH (READCOMMITTEDLOCK) ON match_referee.id_match = inserted.id_match GROUP ...



Top 50 recent answers are included