Is it mandatory to link Membership to Contributions in CiviCRM
For the second part, yes - you can import the contributions Contributions &gt; Import Contributions without linking to memberships which will then show under the Contributions tab.

Contributions are linked to memberships with MembershipPayment so when you have the membership id and contribution id you can link them with:

$result = civicrm_api3('MembershipPayment', 'create', array(
  'membership_id' =&gt; X,
  'contribution_id' =&gt; Y,
));


The challenge here is to get the right membership and contribution id's to pair up.  You could tackle this in various ways including:

1) if you don't mind a bit of coding, write your own import script to create the Contribution, find the relevant Membership then create the MembershipPayment.

2) if you prefer GUI, import your contributions via the UI, export the contributions and memberships (to get the id's), do some spreadsheet manipulation to produce a csv of contribution and membership ids, then use the API CSV Importer extension to import these as MembershipPayments