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.
AnswerAny 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.
AnswerWhen 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.) |
|---|
|
|
|
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?
|
|


