ALTER TABLE [AlleleFreqBySsPop] ADD 
	CONSTRAINT [pk_AlleleFreqBySsPop_b129] PRIMARY KEY  CLUSTERED 
	(
		[subsnp_id],
		[pop_id],
		[allele_id]
	)
GO


ALTER TABLE [Batch] ADD 
	CONSTRAINT [pk_Batch] PRIMARY KEY  CLUSTERED 
	(
		[batch_id]
	),
	CONSTRAINT [ck_batch_type] CHECK ([batch_type]='ANC' OR ([batch_type]='MNT' OR ([batch_type]='VAL' OR ([batch_type]='POP' OR ([batch_type]='IND' OR ([batch_type]='SNP' OR [batch_type]='NOV'))))))
GO


ALTER TABLE [BatchCita] ADD 
	CONSTRAINT [pk_BatchCita] PRIMARY KEY  NONCLUSTERED 
	(
		[batch_id],
		[position]
	)
GO


ALTER TABLE [BatchCommLine] ADD 
	CONSTRAINT [pk_BatchCommLine] PRIMARY KEY  NONCLUSTERED 
	(
		[batch_id],
		[line_num]
	)
GO


ALTER TABLE [BatchCultivar] ADD 
	CONSTRAINT [pk_BatchCultivar] PRIMARY KEY  NONCLUSTERED 
	(
		[batch_id],
		[line_num]
	)
GO


ALTER TABLE [BatchMeExLine] ADD 
	CONSTRAINT [pk_BatchMeExLine] PRIMARY KEY  NONCLUSTERED 
	(
		[batch_id],
		[line_num]
	)
GO


ALTER TABLE [BatchStrain] ADD 
	CONSTRAINT [pk_BatchStrain] PRIMARY KEY  NONCLUSTERED 
	(
		[batch_id],
		[line_num]
	)
GO


ALTER TABLE [BatchValCode] ADD 
	CONSTRAINT [pk_BatchValCode] PRIMARY KEY  CLUSTERED 
	(
		[batch_id]
	)
GO


ALTER TABLE [Contact] ADD 
	CONSTRAINT [pk_Contact] PRIMARY KEY  NONCLUSTERED 
	(
		[batch_id],
		[handle]
	)
GO


ALTER TABLE [FreqSummaryBySsPop] ADD 
	CONSTRAINT [pk_FreqSummaryBySsPop] PRIMARY KEY  CLUSTERED 
	(
		[subsnp_id],
		[pop_id]
	)
GO


ALTER TABLE [GeneIdToName] ADD 
	CONSTRAINT [pk_GeneIdToName] PRIMARY KEY  CLUSTERED 
	(
		[gene_id]
	)
GO


ALTER TABLE [GtyFreqBySsPop] ADD 
	CONSTRAINT [pk_GtyFreqBySsPop_b129] PRIMARY KEY  CLUSTERED 
	(
		[subsnp_id],
		[pop_id],
		[unigty_id]
	)
GO


ALTER TABLE [IndGrpCode] ADD 
	CONSTRAINT [pk_IndGrpCode] PRIMARY KEY  CLUSTERED 
	(
		[code]
	)
GO


ALTER TABLE [IndivBySource] ADD 
	CONSTRAINT [pk_IndivBySource] PRIMARY KEY  NONCLUSTERED 
	(
		[src_id],
		[src_ind_id]
	)
GO



ALTER TABLE [Individual] ADD 
	CONSTRAINT [pk_Individual] PRIMARY KEY  CLUSTERED 
	(
		[ind_id]
	)
GO



ALTER TABLE [Pedigree] ADD 
	CONSTRAINT [p_ped_id] PRIMARY KEY  CLUSTERED 
	(
		[ped_id]
	)
GO


ALTER TABLE [PedigreeIndividual] ADD 
	CONSTRAINT [pk_PedigreeIndividual] PRIMARY KEY  CLUSTERED 
	(
		[ped_id],
		[ind_id]
	)
GO


ALTER TABLE [PopLine] ADD 
	CONSTRAINT [pk_PopLine] PRIMARY KEY  CLUSTERED 
	(
		[pop_id],
		[line_num]
	)
GO


ALTER TABLE [PopMandLine] ADD 
	CONSTRAINT [pk_PopMandLine] PRIMARY KEY  NONCLUSTERED 
	(
		[pop_id],
		[line_num]
	)
GO


ALTER TABLE [Population] ADD 
	CONSTRAINT [pk_Population_pop_id] PRIMARY KEY  CLUSTERED 
	(
		[pop_id]
	)
GO





ALTER TABLE [SNPAlleleFreq] ADD 
	CONSTRAINT [pk_SNPAlleleFreq] PRIMARY KEY  CLUSTERED 
	(
		[snp_id],
		[allele_id]
	)
GO


ALTER TABLE [SNPAncestralAllele] ADD 
	CONSTRAINT [DF__SNPAncest__batch__664F5149] DEFAULT ((0)) FOR [batch_id],
	CONSTRAINT [pk_SNPAncestralAllele] PRIMARY KEY  CLUSTERED 
	(
		[snp_id],
		[batch_id]
	)
GO


ALTER TABLE [SNPGtyFreq] ADD 
	CONSTRAINT [pk_SNPGtyFreq] PRIMARY KEY  CLUSTERED 
	(
		[snp_id],
		[unigty_id]
	)
GO


ALTER TABLE [SNPHWProb] ADD 
	CONSTRAINT [pk_SNPHWProb] PRIMARY KEY  CLUSTERED 
	(
		[snp_id]
	)
GO


ALTER TABLE [SNPHistory] ADD 
	CONSTRAINT [pk_SNPHistory] PRIMARY KEY  CLUSTERED 
	(
		[snp_id]
	)
GO


ALTER TABLE [SNPPubmed] ADD 
	CONSTRAINT [pk_SNPPubmed] PRIMARY KEY  CLUSTERED 
	(
		[snp_id],
		[subsnp_id],
		[pubmed_id],
		[type]
	)
GO




ALTER TABLE [SNPVal] ADD 
	CONSTRAINT [pk_SNPVal] PRIMARY KEY  CLUSTERED 
	(
		[batch_id],
		[snp_id]
	)
GO



ALTER TABLE [SNP_bitfield] ADD 
	CONSTRAINT [pk_SNP_bitfield] PRIMARY KEY  CLUSTERED 
	(
		[snp_id]
	)
GO


ALTER TABLE [SubPop] ADD 
	CONSTRAINT [DF__SubPopB10__last___19AB9A98] DEFAULT (getdate()) FOR [last_updated_time],
	 PRIMARY KEY  CLUSTERED 
	(
		[batch_id],
		[subsnp_id],
		[pop_id],
		[type]
	),
	CONSTRAINT [fk_SubPop_batch_id] FOREIGN KEY 
	(
		[batch_id]
	) REFERENCES [Batch] (
		[batch_id]
	),
	CONSTRAINT [fk_SubPop_pop] FOREIGN KEY 
	(
		[pop_id]
	) REFERENCES [Population] (
		[pop_id]
	),
	 CHECK ([type] = 'GTY' or ([type] = 'HET' or [type] = 'ALE'))
GO


ALTER TABLE [SubPopAllele] ADD 
	CONSTRAINT [fk_SubPopAllele_bid_ss_pop_type] FOREIGN KEY 
	(
		[batch_id],
		[subsnp_id],
		[pop_id],
		[type]
	) REFERENCES [SubPop] (
		[batch_id],
		[subsnp_id],
		[pop_id],
		[type]
	) ON DELETE CASCADE 
GO


ALTER TABLE [SubPopGty] ADD 
	CONSTRAINT [pk_SubPopGty] PRIMARY KEY  CLUSTERED 
	(
		[subpop_id],
		[gty_id]
	)
GO


ALTER TABLE [SubSNP] ADD 
	CONSTRAINT [pk_SubSNP] PRIMARY KEY  CLUSTERED 
	(
		[subsnp_id]
	)
GO


ALTER TABLE [SubSNPAcc_ins] ADD 
	CONSTRAINT [pk_SubSNPAcc] PRIMARY KEY  CLUSTERED 
	(
		[subsnp_id],
		[acc_part],
		[acc_type_ind]
	),
	CONSTRAINT [ck_SubSNPAcc_ins] CHECK ([subsnp_id]>=(30000001) AND [subsnp_id]<=(300000000))
GO


ALTER TABLE [SubSNPCommLine_ins] ADD 
	CONSTRAINT [pk_SubSNPCommLine] PRIMARY KEY  CLUSTERED 
	(
		[subsnp_id],
		[line_num]
	),
	CONSTRAINT [ck_SubSNPCommLine_ins] CHECK ([subsnp_id]>=(30000001) AND [subsnp_id]<=(300000000))
GO


ALTER TABLE [SubSNPHGVS] ADD 
	CONSTRAINT [pk_SubSNPHGVS] PRIMARY KEY  CLUSTERED 
	(
		[subsnp_id]
	)
GO


ALTER TABLE [SubSNPLinkout] ADD 
	CONSTRAINT [DF__SubSNPLin__link___660506BC] DEFAULT ('NA') FOR [link_type],
	CONSTRAINT [pk_SubSNPLinkout] PRIMARY KEY  CLUSTERED 
	(
		[subsnp_id],
		[link_type]
	),
	CONSTRAINT [ck_SubSNPLinkout_link_type] CHECK ([link_type]='NA' OR [link_type]='OTH' OR [link_type]='SRC')
GO


ALTER TABLE [SubSNPMdFailLn] ADD 
	CONSTRAINT [pk_SubSNPMdFailLn] PRIMARY KEY  NONCLUSTERED 
	(
		[subsnp_id],
		[line_num]
	)
GO


ALTER TABLE [SubSNPNoVariSeq] ADD 
	CONSTRAINT [pk_SubSNPNoVariSeq] PRIMARY KEY  NONCLUSTERED 
	(
		[subsnp_id],
		[line_num]
	)
GO


ALTER TABLE [SubSNPOmim] ADD 
	CONSTRAINT [pk_SubSNPOmim] PRIMARY KEY  CLUSTERED 
	(
		[subsnp_id]
	)
GO


ALTER TABLE [SubSNPPubmed] ADD 
	CONSTRAINT [pk_SubSNPPubmed] PRIMARY KEY  CLUSTERED 
	(
		[subsnp_id],
		[line_num]
	)
GO


ALTER TABLE [SubSNPSeq3_ins] ADD 
	CONSTRAINT [pk_SubSNPSeq3] PRIMARY KEY  CLUSTERED 
	(
		[subsnp_id],
		[type],
		[line_num]
	),
	CONSTRAINT [ck_SubSNPSeq3_ins] CHECK ([subsnp_id]>=(30000001) AND [subsnp_id]<=(300000000))
GO


ALTER TABLE [SubSNPSeq5_ins] ADD 
	CONSTRAINT [pk_SubSNPSeq5] PRIMARY KEY  CLUSTERED 
	(
		[subsnp_id],
		[type],
		[line_num]
	),
	CONSTRAINT [ck_SubSNPSeq5_ins] CHECK ([subsnp_id]>=(30000001) AND [subsnp_id]<=(300000000))
GO


ALTER TABLE [SubSNPSeqPos] ADD 
	CONSTRAINT [pk_SubSNPSeqPos] PRIMARY KEY  CLUSTERED 
	(
		[subsnp_id]
	)
GO


ALTER TABLE [SubSNP_top_or_bot] ADD 
	CONSTRAINT [PK__t_ss_top_or_bot__0D5DFFA8] PRIMARY KEY  CLUSTERED 
	(
		[subsnp_id]
	)
GO


ALTER TABLE [SubmittedIndividual] ADD 
	CONSTRAINT [DF__Submitted__ploid__41661CE5] DEFAULT (2) FOR [ploidy],
	CONSTRAINT [pk_SubmittedIndividual] PRIMARY KEY  CLUSTERED 
	(
		[pop_id],
		[loc_ind_id_upp]
	)
GO


ALTER TABLE [Synonym] ADD 
	CONSTRAINT [pk_Synonym] PRIMARY KEY  NONCLUSTERED 
	(
		[subsnp_id],
		[type]
	)
GO


ALTER TABLE [b132_ContigInfo_37_1] ADD 
	CONSTRAINT [pk_b132_ContigInfo] PRIMARY KEY  CLUSTERED 
	(
		[ctg_id]
	)
GO







ALTER TABLE [b132_SNPContigLoc_37_1] ADD 
	CONSTRAINT [ck_snp_type] CHECK ([snp_type]='rs')
GO


ALTER TABLE [b132_SNPContigLocusId_37_1] ADD 
	CONSTRAINT [ck_fxn] CHECK ([fxn_class]=(75) OR [fxn_class]=(73) OR [fxn_class]=(55) OR [fxn_class]=(53) OR [fxn_class]=(45) OR [fxn_class]=(44) OR [fxn_class]=(43) OR [fxn_class]=(42) OR [fxn_class]=(41) OR [fxn_class]=(15) OR [fxn_class]=(13) OR [fxn_class]=(8) OR [fxn_class]=(6) OR [fxn_class]=(3))
GO


ALTER TABLE [b132_SNPMapInfo_37_1] ADD 
	CONSTRAINT [ck_SNPMapInfo_snp_type] CHECK ([snp_type]='rs')
GO


ALTER TABLE [dn_IND_batchCount] ADD 
	CONSTRAINT [pk_dn_IND_batchCount] PRIMARY KEY  NONCLUSTERED 
	(
		[batch_id],
		[pop_id]
	)
GO



ALTER TABLE [dn_PopulationIndGrp] ADD 
	CONSTRAINT [pk_dn_PopulationIndGrp] PRIMARY KEY  CLUSTERED 
	(
		[pop_id]
	)
GO


ALTER TABLE [dn_batchCount] ADD 
	CONSTRAINT [pk_dn_batchCount] PRIMARY KEY  NONCLUSTERED 
	(
		[batch_id]
	)
GO


ALTER TABLE [dn_handleCount] ADD 
	CONSTRAINT [pk_dn_handleCount] PRIMARY KEY  NONCLUSTERED 
	(
		[handle],
		[batch_type]
	)
GO




