Join Bill Weinman for an in-depth discussion in this video Databases and tables, part of SQL Essential Training.
A database is, fundamentally, a collection of tables. Depending on which database management system you're using, a database may also include any number of other things, indexes, triggers, stored procedures, and other metadata. But fundamentally, a database is a collection of tables. A table is a collection of data organized in rows and columns. Normally a table is a collection of relate things, like countries in a country table. Or customers in a customer table. Tables may have relationships with other tables, for example.
A customer may have one or more addresses, so the address table would have a customer ID column, that links to records in the customer table. These kinds of relationships are common, customers have addresses, record albums, have tracks, countries have cities. Likewise, the tables in the database are generally related to each other. While many systems allow queries to cross databases, the tables in a database are typically used by one application, Or a set of applications and the tables used by different applications are typically kept in different databases.
So a database is organized as a set of tables where each table contains a common set of data. The specifics of how a database is defined and what it contains varies somewhat From system to system, but generally the tables in a database tend to be related to each other like countries, regions, and cities. Or customers and addresses. Understanding how a database is organized can help you to understand your application or the application you need to work with.
- Understanding SQL terminology and syntax
- Creating new tables and records
- Inserting and updating data
- Writing basic SQL queries
- Sorting and filtering
- Accessing related tables with JOIN
- Working with strings
- Finding the numeric type of a value
- Using aggregate functions and transactions
- Updating a table with triggers
- Creating views
Skill Level Beginner
Q: For Mac OS X: When I try to start the Apache Web Server from the XAMPP control panel, it doesn't start, and when I open "localhost" in my web browser, I see a white screen that says "It Works!" instead of the XAMPP page.
<div id="pastingspan1">A: This usually means that you have the Apple version of the Apache Web Server already running.</div> <div> </div> <div id="pastingspan1"></div> <div id="pastingspan1">Apple provides a version of the Apache Web Server with OS X. I chose to use XAMPP because it includes PHP and the MySQL server all in one package.</div> <div> </div> <div id="pastingspan1"></div> <div id="pastingspan1">You cannot install XAMPP with Apache already running on your Mac. If you see "It works!" when you open your browser and type "localhost" into the address bar, this means that the Apple version of Apache is already running. You cannot run two instances of a web server at once, so the Apple Apache must be stopped before you can install XAMPP.</div> <div> </div> <div id="pastingspan1"></div> <div id="pastingspan1">In OSX 10.7 and earlier, you could start and stop the Apache Web Server in Control Panel, by choosing "Sharing" and then unchecking the "Web Sharing" checkbox. As of 10.8 this option is no longer in the control panel.</div> <div> </div> <div id="pastingspan1"></div> <div id="pastingspan1">To disable Apple's version of Apache in current versions of OS X, open a Terminal window and type this command:</div> <div> </div> <div id="pastingspan1"></div> <blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"> <div id="pastingspan1">sudo apachectl stop</div> <div> </div> </blockquote> <div id="pastingspan1"></div> <div id="pastingspan1">You will need to type your system password when prompted, then you should be able to start the XAMPP version of Apache.</div>
Q: I'm on a Mac, and I get an error in SID that says "attempt to write a read only database." How can I fix this?
<p>A: This usually means that the database folder does not have sufficient permissions for writing by the web user. This can happen if you create the SQL folder new, rather than copying it from the Exercise Files. Here's how to fix this: </p> <blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"> <p> </p><ol> <li>Open a Finder window and Navigate to /Applications/XAMPP/htdocs/SQL</li> <li>Control-click on the SQL folder and select "Get Info" from the context menu. </li> <li>Under "Sharing and Permissions" (you may need to open the disclosure triangle), in the "everyone" row, select "Read & Write."Then you can close the Info window. </li> <li>Now repeat the process for the three *.db files inside the folder. </li> </ol> <p> </p> </blockquote>