A database is a collection of information organized in such a way that a computer program can quickly select desired pieces of data based on a query that you provide. As previously mentioned, databases are the storage sites for the world's data. Database services are based on a client/server model. In SUSE Linux, you can install components based on that model for both the client and the server portions of the database. You can install a database server by installing MySQL. You can also use various database clients to access the database service running on your system. By installing the service, you install the software needed to run, operate, and manage database protocols such as SQL. SQL stands for Structured (or Standard) Query Language; it is a standard language for accessing and manipulating databases. SQL defines statements that can be used to retrieve and update data in a database, such as SELECT, UPDATE, DELETE, INSERT, and WHERE. You can access a MySQL database in various ways via the command prompt using the mysql command, using specialized client software such as Knoda, or through a web browser. Before getting too far into this chapter, we need to discuss how databases work. There are two general types of databases: flat-file databases, which are much like your /etc/passwd file, and relational databases, which are much more complex and require much more "structure" to organize them. Flat-file databases are poor performers and are not truly scalable. A flat-file database is the opposite of a relational database, which is hierarchical. Relational databases, on the other hand, are specialized to handle large amounts of data. They are scalable, which means that they grow well, unlike their flat-file counterparts. Relational databases are organized by fields, records, and tables. In a relational database, a field is a single piece of information. A record is one complete set of fields, and a table is a collection of records. This is essentially what makes up the logical structure of databases. In a database, each table is identified by a name, such as Contacts. Each table contains records, also called rows, that contain the actual database data. For example, suppose we were to define a table called Contacts and create the following three records: Last First Address City State Coughanour David 578 E. 200 N. Santaquin Utah Johnson Brian 113 N. 1111 E. Rigby Idaho Corry Jason 57 E. Wrangler San Antonio Texas Using the SQL language, you can create queries that return specific data from the database. For example, suppose you were to compose the following query: SELECT Last FROM Contacts The database would return the following data: Last Coughanour Johnson Corry In addition to creating queries, the SQL language also allows you to update, insert, and delete records. This is done using the following commands:
In addition to manipulating data within a table, SQL commands can also be used to manage the table itself. This is done using the following commands:
A key feature of a relational database is that you can create "relations" between tables, which enables you to create powerful interrelated data sets. A relational database is also known as a relational database management system (or RDBMS). RDBMS is a type of database management system (DBMS), but this one focuses on the relational model just discussed. When you install the database service with YaST, you can create the system of fields and such where the data will be stored and organized in a way that information can be managed efficiently. If data is managed this way, it is quick to retrieve and easier to manage, mine, and control. |