If you only had two tables, Session and Booking, you could do this:
- Add CourseSizeMax column to your dbo.Session table, and add a UNIQUE constraint on [dbo].[Session]([ID], [CourseSizeMax]) - it is needed later.
- Add CourseSizeMax column, and BookingNumber column to your dbo.Booking table.
- Add a FK constraint on dbo.Booking(CourseId, CourseSizeMax) referring to Session
- Add a CHECK(BookingNumber BETWEEN 1 AND CourseSizeMax)
- Add a UNIQUE constraint on dbo.Booking(CourseId, BookingNumber)
and you are all set, as long as all your constraints are trusted.
I am not sure why would you need the third table CourseSize at all.