What is the difference between a file and a database?

Answer

Simply put, a file is a collection of bytes stored together. An example of a file could be a Text File (a collection of alphanumeric characters that, when put together, form a readable document) or a Bitmap Image File (a collection of bytes that software would then interpret as elements of an image).

A database is a special type of file that holds many tables. Each table can hold many fields as well as records. Think of a table as a spreadsheet. Each column represents different fields, such as "UserID", "LastName", and "CityOfResidence". Each row represents a record, or an entry, in the table, such as an entry for John Smith who lives in Albuquerque.

An example of a database would be one that has three tables: Books, Instructors, and Courses. Different fields in the "Books" table would be "Author", "Publisher", "Title", and "ISBN". Different records within "Books" would be, for example, an entry for "Learning Java in 20 Days" (Title) by John C. Doe (Author), published by ABC Publishing Co. (Publisher).

Each table in a database requires one field to be designated as the Primary Key. This means that, in order to uniquely identify a record in a table, one field needs to be used. In a "Students" table, the "StudentID" could be used as the Primary Key, since no two records (students) can have the same Student ID. For "Books" it could be "ISBN", since that is unique per book title.

Visually, a table would look something like this:

"Books" Table

ISBN Title Author Publisher 1234567 "Learning Java" Bob Smith ABC Publishing 8675309 "Plumbing Basics" Joe Public XYZ Inc. 6762786 "American Literature" William Jones LMNOP Corp.

Finally, keep the following in mind: a database is a type of file. Therefore, all databases are files, '''but''' not all files are databases.

Answer

Any chunk of data you save is a file. Ten words of text in notepad, or a dozen images in a folder. Those are both files. A database is both a program to store and organize data, and make it searchable, and the data contained in it. I guess you could call a database a file as well, but they are typically large, and referred to as databases. You might search a product database for widgets of wool, orange in color, made in New Zealand. The result of that search you could also call a file.

Answer

When database managment systems (DBMS) first were developed, they used multiple files per database, typically one file per table. Now days, most of the common DBMS systems use one file per database. A database is a type of file (or a group of files.)

 

Improve Answer Discuss the question "What is the difference between a file and a database?" Watch Question

First answer by ID1153386616. Last edit by Eisaacs. Contributor trust: 44 [recommend contributor]. Question popularity: 33 [recommend question]


Research your answer:

Can you answer other questions about databases and data management systems?

Answers.com > Wiki Answers > Categories > Technology > Computers > Computer Databases > What is the difference between a file and a database?

Our contributors said this page should be displayed for the questions below. (Where do these come from)
If any of these are not a genuine rephrasing of the question, please help out and edit these alternates.
Compare file with database?  File system vs database sytem?  Difference between database and file?  Difference between file and database?  Diff between file system and database?  What is the difference between a file?  Difference between File and a Database?  Comparison between file and database system?  What is the diff bw a file system and a database?  What is the difference between file and database?  How does the operation of a database differ from one using convensional file structure?