Apex is a development platform for building software as a service (SaaS) applications on top of Salesforce.com's customer relationship management (CRM) functionality. Apex allows developers to access Salesforce.com's back-end database and client-server interfaces to create third-party SaaS applications.
Visualforce pages are webpages that belong to Salesforce. These webpages are created using a unique tag-based Mark-up language. It is similar to HTML but it's primary use is to access, display and update the organization's data. The page is accessed by using a URL similar to that of a traditional webserver page.
Lightning (Salesforce Lightning) is a component-based framework for app development from Salesforce.com that is designed to simplify processes for business users, who typically do not have programming experience. ... Lightning features: Experience, a graphical user interface (GUI) that is optimized for speed.
This video talks about Data access best practices for Apex, Visualforce and Lightning