MySql_Alter.sql 3.38 KB
/**
 * @filesource MySql_Alter.sql
 *
 * @category freeSN
 * @copyright Copyright by mensch.coop e.G. 2009
 * @mailto	dev [at] mensch.coop
 * @version 0.4.200901
 * @link http://mensch.coop
 */
select 'MySql_Alter.sql';

select 'INDEX';
	ALTER TABLE losp_BasisElement ADD INDEX ID (ID);
-- 	ALTER TABLE losp_BasisElement ADD INDEX ID (ID);

select 'FOREIGN KEYs';

select ' - losp_BE_profile';
	ALTER TABLE losp_BE_profile
		ADD CONSTRAINT BE_profile_MTextID__BasisElement_ID
			FOREIGN KEY (MTextID) REFERENCES losp_BasisElement(ID)
			ON DELETE CASCADE ON UPDATE CASCADE;

select ' - losp_BE_topic';
	ALTER TABLE losp_BE_topic
		ADD	CONSTRAINT BE_topic_MTextID__BasisElement_ID
			FOREIGN KEY (MTextID) REFERENCES losp_BasisElement(ID)
			ON DELETE CASCADE;

select ' - losp_BasisElement';
-- 	ALTER TABLE losp_BasisElement

-- 			geht nicht, da wenn auch nur ein einzelner Eintrag von der Liste gelöscht wird, beschwert er sich!!
-- 		ADD CONSTRAINT BE_AuthWriteListID__BE_writeauthorisation_ListID
-- 			FOREIGN KEY (AuthWriteListID) REFERENCES losp_BasisElement_writeauthorisation(ListID),
-- 			geht nicht, da wenn auch nur ein einzelner Eintrag von der Liste gelöscht wird, beschwert er sich!!
-- 		ADD CONSTRAINT BE_AuthReadListID__BE_readauthorisation_ListID
-- 			FOREIGN KEY (AuthReadListID) REFERENCES losp_BasisElement_readauthorisation(ListID)

-- 			;


select ' - losp_BasisElementDesign';
	ALTER TABLE losp_BasisElementDesign
		ADD CONSTRAINT BED_Author_ProfileID___BE_profile_MTextID
			FOREIGN KEY (Author_ProfileID) REFERENCES losp_BE_profile(MTextID)
			ON DELETE SET NULL ON UPDATE CASCADE;

select ' - losp_BasisElementDesign_values';
	ALTER TABLE losp_BasisElementDesign_values
		ADD CONSTRAINT BED_values_ID__BED_ID
			FOREIGN KEY (ID) REFERENCES losp_BasisElementDesign(ID)
			ON DELETE CASCADE ON UPDATE CASCADE;

select ' - losp_BasisElement_categorynamelist';
	ALTER TABLE losp_BasisElement_categorynamelist
		ADD CONSTRAINT BEC_namelist_BECategoryGroupID__BEC_namelist_BECategoryID
			FOREIGN KEY (BECategoryGroupID) REFERENCES losp_BasisElement_categorynamelist(BECategoryID)
 			ON DELETE CASCADE ON UPDATE CASCADE;

select ' - losp_be_account';
	ALTER TABLE losp_be_account
		ADD CONSTRAINT be_account__BE_profile_MTextID
			FOREIGN KEY (ProfileID) REFERENCES losp_BE_profile(MTextID)
			ON DELETE SET NULL ON UPDATE CASCADE;


select ' - losp_BasisClipboard';
	ALTER TABLE losp_BasisClipboard
		ADD CONSTRAINT BC_PartOfID__BasisElement_ID
			FOREIGN KEY (PartOfID) REFERENCES losp_BasisElement(ID)
			ON DELETE CASCADE ON UPDATE CASCADE,
		ADD CONSTRAINT BC_AttachID___BasisElement_ID
			FOREIGN KEY (AttachID) 	REFERENCES losp_BasisElement(ID)
			ON DELETE CASCADE ON UPDATE CASCADE,
		ADD CONSTRAINT BC_AttachStateID__BasisClipboard_state_StateID
			FOREIGN KEY (AttachStateID) REFERENCES losp_BasisClipboard_state(StateID)
			ON DELETE CASCADE ON UPDATE CASCADE,
		ADD CONSTRAINT BC_CategoryID__BasisClipboard_category_CategoryID
			FOREIGN KEY (CategoryID) REFERENCES losp_BasisClipboard_category(CategoryID)
			ON DELETE CASCADE ON UPDATE CASCADE,
		ADD CONSTRAINT BC_PartOfObjVarID__BasisClipboard_objvar_PartOfObjVarID
			FOREIGN KEY (PartOfObjVarID) REFERENCES losp_BasisClipboard_objvar(PartOfObjVarID)
			ON DELETE CASCADE ON UPDATE CASCADE,
		ADD CONSTRAINT BC_LinkerProfileID__losp_BE_profile_MTextID
			FOREIGN KEY (LinkerProfileID) REFERENCES losp_BE_profile(MTextID)
			ON DELETE CASCADE ON UPDATE CASCADE
	;