SCII interview question

Basic database related and some technical logic