Personally, I think that the only way a kid learns about edges of beds is to fall off once or twice. I think my 2 yo fell three times, but that was a long time ago and I can't remember for certain.
My now 11-mo has fallen once, while he was asleep, and once while awake and DH wasn't watching. While asleep, he scoots on his belly, and I suspect he went over head-first, losing his balance. While awake, he now stops when he gets close to the edge, but sometimes in the process of turning around to sit up, his bottom gets too close to the edge and he slips over.
Basically, as soon as each of my boys started crawling towards the edge, we started teaching them about turning around and getting off feet first. It takes awhile to teach them that, but I think it's important to give them that freedom/tool early rather than later. I don't know about your kids, but my boys are persistent and insistent about going where they want, when they want -- if I didn't teach them how to get off, they'd just continue to plow over the edge, looking for a way that worked, themselves.
If you're asking more in the context about rolling off during sleep, I'd suggest you get one of those baby fence things -- they're certainly not perfect, but if your child is getting to be mobile on the floor and able to get to the floor while awake, I think that's the time to use one.