SQL Server databases have three types of files:
Primary data files
Primary data file is the starting point of the database. It points towards other files in the database. Every database has one primary data file. Recommended file extension for primary data file is .mdf.
Secondary data files
All data files other than the primary data file in a database are secondary data files. These are optional and may be added for further requirements. Recommended extension for secondary data files is .ndf.
Transaction log files hold all the log information used to recover the database and individual transactions. At least one log file is required for each database. Recovery models of the database affect the growth of log files. Recommended extension for log files is .ldf.
It is notable that SQL Server does not enforce the recommended extensions, but for proper and standard environment these should not be changed.