I would make the top an inch or two lower than the mattress top. I also think it is a good idea to have a decent top overhang on the sides near the bed, since that lets you butt the table top up against the mattress and keeps stuff from falling in between them when someone is flailing for the alarm clock. Same for the back if you will be blocking the power outlets you need to use (which seems to always be the case). If you like small bedside lamps you could build a small raised portion on the top toward the rear of the nightstand to accommodate lamps and maybe a small drawer underneath that part.