Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What is the difference between a file with .db extension and a normal file with .txt extension , leaving the fact that a .db extension is for a database file and .txt makes a normal text file.

I open a text editor and make 5 entries :

First Entry : Ghazal
Second Entry : Qateel Shifai
Third Entry : Faiz Ahmed Faiz
Fourth Entry : Jigar Moradabadi
Fifth Entry : Ahmed Faraz

What do I gain if I save the above data in a file with .db extension while not saving with .txt extension ?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

For the file: nothing.

The file will be treated in exactly the same way.

If you try to open the file with a program then there can be a difference depending on the program.

E.g. if I use somepictureViewer picture then there are three things which can happen:

  1. The program will look inside the file to determine it type. This is why many files start with something called MagicNumbers. (e.g. a JPEG file will usually start with JFIF in the first bytes. A .gif file with GIF87 or GIF89. A PDF with PDF13, etc etc. This is the clean, neat way.
  2. The program will try to open the file and assume it is the default format. This might leads to some messed up contents if it guesses wrong.
  3. The program will look at its extension and assume that a specific extension belongs to a specific file format. This can work out great and this can produce horrible results.

The most obvious example in this is with windows, where I can open a file called demo.xls and the default settings make the assumption that a file ending in .xls is an excel file. If it is, then things work great. If it happens to be a misnamed picture (and yes, I have seen this in the wild with clueless users trying to get a picture inside an excell sheet) then things will simply go wrong.

But for the file itself: Nothing changes.

share|improve this answer
    
and can you please answer the ..what do I gain part of the question ? –  Suhail Gupta Jan 8 '13 at 17:25
    
Depending on the OS: Either nothing or automatic opening with a specific program. (Read: if you use windows you can set it to automatically open all programs with an extension of your choice with a chosen program). –  Hennes Jan 8 '13 at 17:31
    
as an application developer what do I gain ? –  Suhail Gupta Jan 8 '13 at 17:35
    
Nothing at all since the file stays precisely the same. –  Hennes Jan 8 '13 at 17:39
1  
@SuhailGupta To Hennes' point, as an application developer, you can be confident that your file is not going to be opened in Notepad on your end user's system by default, and help keep it from being inadvertently deleted. So, in the opposite, by naming it .db, you gain having it NOT open with a specific program by default. A filename and extension can convey a file's intended purpose or relationship with other files. –  maxwellb Jan 8 '13 at 18:42
show 1 more comment

Just a note on the 'what do I gain?' part of the question.

If you luck out, and have a particular database program that reads flat files with a .db extension, and saves files in the format you've specified - ie 1 record per file (maybe with a colon at the beginning of the record) - then when you double-click that .db file, it will open in the database program.

So if you develop an application that reads files in that format, you can use associations to set the file to open your program by default (on double-click or right-click, open)

share|improve this answer
    
When I try to open the .db file that looked like this via MySql GUI tool, I see nothing in it –  Suhail Gupta Jan 8 '13 at 18:04
    
Therefore mysql's .db files are not formatted like your .db file. –  mcalex Jan 9 '13 at 0:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.