Grauenwolf / HemaDrillBook

A Historical European Martial Arts (HEMA) research tool
MIT License
3 stars 0 forks source link

Delete unused tags #89

Open Grauenwolf opened 4 years ago

Grauenwolf commented 4 years ago

This will be needed before we start working on #70.

DELETE FROM Tags.Footwork WHERE NOT EXISTS (SELECT * FROM Interpretations.PlayStep ps WHERE ps.FootworkKey = Footwork.FootworkKey)

DELETE FROM Tags.Guard WHERE NOT EXISTS (SELECT * FROM Interpretations.PlayStep ps WHERE ps.GuardKey = Guard.GuardKey OR ps.IntermediateGuardKey = Guard.GuardKey)
AND NOT EXISTS (SELECT * FROM Interpretations.Play p WHERE p.AGuardKey = Guard.GuardKey OR p.PGuardKey = Guard.GuardKey)

DELETE FROM Tags.GuardModifier WHERE NOT EXISTS (SELECT * FROM Interpretations.PlayStep ps WHERE ps.GuardModifierKey = GuardModifier.GuardModifierKey OR ps.IntermediateGuardModifierKey = GuardModifier.GuardModifierKey)
AND NOT EXISTS (SELECT * FROM Interpretations.Play p WHERE p.AGuardModifierKey = GuardModifier.GuardModifierKey OR p.PGuardModifierKey = GuardModifier.GuardModifierKey)

DELETE FROM Tags.Measure WHERE NOT EXISTS (SELECT * FROM Interpretations.Play p WHERE p.MeasureKey = Measure.MeasureKey)

DELETE FROM Tags.Target WHERE NOT EXISTS (SELECT * FROM Interpretations.PlayStep ps WHERE
ps.TargetKey1 = Target.TargetKey OR
ps.TargetKey2 = Target.TargetKey OR
ps.TargetKey3 = Target.TargetKey )

DELETE FROM Tags.Technique WHERE NOT EXISTS (SELECT * FROM Interpretations.PlayStep ps WHERE
ps.TechniqueKey1 = Technique.TechniqueKey OR
ps.TechniqueKey2 = Technique.TechniqueKey OR
ps.TechniqueKey3 = Technique.TechniqueKey )

DELETE FROM Tags.Weapon WHERE NOT EXISTS (SELECT * FROM Sources.SectionWeaponMap swm WHERE swm.PrimaryWeaponKey = Weapon.WeaponKey OR swm.SecondaryWeaponKey = weapon.WeaponKey)