clear markdown compare help donate or buy diddy dollings comments/suggestions/bugs a leap of faith? bible365
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 582680 fiddles created (13279 in the last week).

CREATE TABLE PartyType ( PartyTypeCode CHAR(1) NOT NULL, Name CHAR(30) NOT NULL, -- CONSTRAINT PartyType_PK PRIMARY KEY (PartyTypeCode) ); CREATE TABLE Party ( PartyId INT NOT NULL, PartyTypeCode CHAR(1) NOT NULL, CreatedDateTime TIMESTAMP NOT NULL, -- CONSTRAINT Party_PK PRIMARY KEY (PartyId), CONSTRAINT PartyToPartyType_FK FOREIGN KEY (PartyTypeCode) REFERENCES PartyType (PartyTypeCode) ); CREATE TABLE Person ( PersonId INT NOT NULL, FirstName CHAR(30) NOT NULL, LastName CHAR(30) NOT NULL, GenderCode CHAR(3) NOT NULL, BirthDate DATE NOT NULL, -- CONSTRAINT Person_PK PRIMARY KEY (PersonId), CONSTRAINT Person_AK UNIQUE (FirstName, LastName, GenderCode, BirthDate), CONSTRAINT PersonToParty_FK FOREIGN KEY (PersonId) REFERENCES Party (PartyId) ); CREATE TABLE Organization ( OrganizationId INT NOT NULL, Name CHAR(30) NOT NULL, FoundingDate DATE NOT NULL, -- CONSTRAINT Organization_PK PRIMARY KEY (OrganizationId), CONSTRAINT Organization_AK UNIQUE (Name), CONSTRAINT OrganizationToParty_FK FOREIGN KEY (OrganizationId) REFERENCES Party (PartyId) ); CREATE TABLE ProductType ( ProductTypeCode CHAR(1) NOT NULL, Name CHAR(30) NOT NULL, -- CONSTRAINT ProductType_PK PRIMARY KEY (ProductTypeCode) ); CREATE TABLE Product ( OrganizationId INT NOT NULL, ProductNumber INT NOT NULL, ProductTypeCode CHAR(1) NOT NULL, CreatedDateTime DATETIME NOT NULL, -- CONSTRAINT Product_PK PRIMARY KEY (OrganizationId, ProductNumber), CONSTRAINT ProductToOrganization_FK FOREIGN KEY (OrganizationId) REFERENCES Organization (OrganizationId), CONSTRAINT ProductToProductType_FK FOREIGN KEY (ProductTypeCode) REFERENCES ProductType (ProductTypeCode) ); CREATE TABLE SystemType ( SystemTypeCode CHAR(1) NOT NULL, Name CHAR(30) NOT NULL, -- CONSTRAINT SystemType_PK PRIMARY KEY (SystemTypeCode) ); CREATE TABLE MySystem ( OrganizationId INT NOT NULL, SystemNumber INT NOT NULL, SystemTypeCode CHAR(1) NOT NULL, ParticularColumn CHAR(30) NOT NULL, -- CONSTRAINT System_PK PRIMARY KEY (OrganizationId, SystemNumber), CONSTRAINT SystemToProduct_FK FOREIGN KEY (OrganizationId, SystemNumber) REFERENCES Product (OrganizationId, ProductNumber), CONSTRAINT SystemToSystemType_FK FOREIGN KEY (SystemTypeCode) REFERENCES SystemType (SystemTypeCode) ); CREATE TABLE Game ( OrganizationId INT NOT NULL, GameNumber INT NOT NULL, SpecificColumn CHAR(30) NOT NULL, -- CONSTRAINT Game_PK PRIMARY KEY (OrganizationId, GameNumber), CONSTRAINT GameToProduct_FK FOREIGN KEY (OrganizationId, GameNumber) REFERENCES Product (OrganizationId, ProductNumber) ); CREATE TABLE Genre ( GenreNumber INT NOT NULL, Name CHAR(30) NOT NULL, Description CHAR(90) NOT NULL, -- CONSTRAINT Genre_PK PRIMARY KEY (GenreNumber), CONSTRAINT Genre_AK1 UNIQUE (Name), CONSTRAINT Genre_AK2 UNIQUE (Description) ); CREATE TABLE SystemGame ( SystemOrganizationId INT NOT NULL, SystemNumber INT NOT NULL, GameOrganizationId INT NOT NULL, GameNumber INT NOT NULL, CreatedDateTime DATETIME NOT NULL, -- CONSTRAINT SystemGame_PK PRIMARY KEY (SystemOrganizationId, SystemNumber, GameOrganizationId, GameNumber), CONSTRAINT SystemGameToSystem_FK FOREIGN KEY (SystemOrganizationId, SystemNumber) REFERENCES MySystem (OrganizationId, SystemNumber), CONSTRAINT SystemGameToGame_FK FOREIGN KEY (SystemOrganizationId, GameNumber) REFERENCES Game (OrganizationId, GameNumber) ); CREATE TABLE GameGenre ( GameOrganizationId INT NOT NULL, GameNumber INT NOT NULL, GenreNumber INT NOT NULL, CreatedDateTime DATETIME NOT NULL, -- CONSTRAINT GameGenre_PK PRIMARY KEY (GameOrganizationId, GameNumber, GenreNumber), CONSTRAINT GameGenreToGame_FK FOREIGN KEY (GameOrganizationId, GameNumber) REFERENCES Game (OrganizationId, GameNumber), CONSTRAINT GameGenreToGenre_FK FOREIGN KEY (GenreNumber) REFERENCES Genre (GenreNumber) ); CREATE TABLE Job ( OrganizationId INT NOT NULL, ProductNumber INT NOT NULL, JobNumber INT NOT NULL, Title CHAR(30) NOT NULL, CreatedDateTime DATETIME NOT NULL, -- CONSTRAINT Job_PK PRIMARY KEY (OrganizationId, ProductNumber, JobNumber), CONSTRAINT Job_AK UNIQUE (Title), CONSTRAINT JobToProduct_FK FOREIGN KEY (OrganizationId, ProductNumber) REFERENCES Product (OrganizationId, ProductNumber) ); CREATE TABLE Collaborator ( CollaboratorId INT NOT NULL, OrganizationId INT NOT NULL, ProductNumber INT NOT NULL, JobNumber INT NOT NULL, AssignedDateTime DATETIME NOT NULL, -- CONSTRAINT Collaborator_PK PRIMARY KEY (CollaboratorId, OrganizationId, ProductNumber, JobNumber), CONSTRAINT CollaboratorToPerson_FK FOREIGN KEY (CollaboratorId) REFERENCES Person (PersonId), CONSTRAINT CollaboratorToJob_FK FOREIGN KEY (OrganizationId, ProductNumber, JobNumber) REFERENCES Job (OrganizationId, ProductNumber, JobNumber) );
 hidden batch(es)