Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Try this quiz. It's based on a quiz I saw posted on HN a while back.

http://sqlfiddle.com/#!3/3973f/1

Edit: I'm not allowed to reply just yet, so I'll post here.

You need to add the boss first to the employee table with a NULL bossID.

Then you add another employee that has a bossID that refers to that last added record.



Aww - no test data? And when trying to add test data, I get errors due to the self-referencing foreign key. Perhaps the schema could do with a

> DEFAULT (IDENT_CURRENT('dbo.Employees'))

on the BossID column. Been awhile (years) since I've worked with SQL Server.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: