What your asking is no simple question. There is no way I could explain it all in one post. You need to do alot of learning and research before you tackle something like this. You will need a good grasp of a programming/scripting language and SQL for databases.
If your already put off, have a look at some Open source social networking software. Should get the job done, if that's your only goal.
Some social networking software:
iSocial
mahara
“The best thing about a boolean is even if you are wrong, you are only off by a bit.”