SQL constraint on recording