Filesystem vs Database
Database and File System are two methods used to store, retrieve, manage and manipulate data. Both systems can be used to allow the user to work with data in a similar way. A File System is a collection of raw data files stored in the hard-drive, whereas a database is intended for easily organizing, storing and retrieving large amounts of data. In other words, a database holds a bundle of organized data (typically in a digital form) for one or more users. Databases, often abbreviated DB, are classified according to their content, such as document-text, bibliographic and statistical. It should be noted that, even in a database, data are eventually (physically) stored in some sort of files.
What is a File system?
As mentioned above, in a typical File System electronic data are directly stored in a set of files. If only one table is stored in a file, it is called a flat file. They contain values in each row separated with a special delimiter like commas. In order to query some random data, first it is required to parse each row and load it to an array at run time, but for this file should be read sequentially (because, there is no control mechanism in files); therefore it is quite inefficient and time consuming. The burden of locating the necessary file, going through the records (line by line), checking for the existence of a certain data and remembering what files/records to edit are on the user. The user either has to perform each task manually or has to write a script that does them automatically with the help of the file management capabilities of the operating system. Because of these reasons, File Systems are easily vulnerable to serious issues like inconsistency, inability to maintain concurrency, data isolation, threats on integrity and lack of security.
What is a Database?
A Database may contain different levels of abstraction in its architecture. Typically, the three levels: external, conceptual and internal make up the database architecture. External level defines how the users view the data. A single database can have multiple views. The internal level defines how the data is physically stored. The conceptual level is the communication medium between internal and external levels. It provides a unique view of the database regardless of how it is stored or viewed. There are several types of databases such as Analytical databases, Data warehouses and Distributed databases. Databases (more correctly, relational databases) are made up of tables, and they contain rows and columns, much like spreadsheets in Excel. Each column corresponds to an attribute while each row represents a single record. For example, in a database, which stores employee information of a company, the columns could contain employee name, employee Id and salary, while a single row represents a single employee. Most databases come with a Database Management System (DBMS) that makes it very easy to create/manage/organize data.
What is the difference between File system and Database?
As a summery, in a File System, files are used to store data while, a database is a collection of organized data. Although File System and databases are two ways of managing data, databases clearly have many advantages over File Systems. Typically when using a File System, most tasks such as storage, retrieval and search are done manually (even though most operating systems provide graphical interfaces to make these tasks easier) and it is quite tedious whereas when using a database, the inbuilt DBMS will provide automated methods to complete these tasks. Because of this reason, using a File System will lead to problems like data integrity, data inconsistency and data security, but these problems could be avoided by using a database. Unlike a File System, databases are efficient because reading line by line is not required, and certain control mechanisms are in place.