-2
create table Game(

isOn boolean,

playHour int,

isOff boolean,

constraint ck_isOn_hour check ( ? )

);

Constraint : playHour is NULL when isOn = FALSE

Replace the '?' symbol with a valid check for the given constraint.

Any help is much appreciated.

cabrillosa
  • 155
  • 8
kris
  • 1
  • 1

1 Answers1

0

This should do it:

constraint ck_isOn_hour check (isOn or (playHour is null and not isOn))

This can be simplified:

constraint ck_isOn_hour check (isOn or playHour is NULL)
GMB
  • 216,147
  • 25
  • 84
  • 135