Automatic blog creation with registered username as blog url.

Is there a way to have a blog automatically made when a user registers and their username as the blog url?

I would like to set this up so my affiliates could sign up and a blog with their username is created for them with their username.

I will need to add their reference like: ?ref=username

So their blog url will look like this:

Can someone help me with a function that can automate this for me.