Custom Plugin Development

I am new to Sugar CRM. How can i create plugin for built-in and custom modules ? And how to maintain relationships and everything else that i did for all the modules in plugin?