Jul 18, 2010 0
Basic Programming for Databases, part 1
1. Database Design
The architecture of a database management system
Let’s go over two focal points of database design: the layout of a database system and the proper way to design a database for programming. Please note that every bit of information will not be completely correct at the granular level to facilitate the learning process.
A database system (we will be focusing on Microsoft SQL Server) can be described as a database computing server. I’ll break down how a database is set up.
A record is a single set of information. A record could be a single customer, an order line item, a calendar event, or a Facebook wall post. A record represents the smallest logical grouping of information within a RDBMS (Relational Database Management System).
Similar records (customer records, for this example) are grouped into a table (a table looks similar to an Excel spreadsheet). Records are rows and have data separated into columns. Each column has the same type of data. A customer record may contain a first name, last name, and e-mail address. All of those columns are text columns. A customer record may also have an identification number, which would be a number column.

This is a database table
Tables that relate to one another and serve to store data for a single application typically reside on the same database (not to be confused with the entire RDBMS). A customer relationship management system may have an order, order line item, customer, employee, and inventory tables. These tables would be grouped into a database, perhaps called CRM.
Multiple databases are thrown together on the same instance. A SQL Server instance can be considered a virtualized server, enabling multiple instances to operate in parallel. Why would you use multiple instances? Instances are crammed onto a SQL Server RDBMS. A single SQL Server RDBMS is genrally allocated a dedicated computer, meaning nothing else typically operates on that computer (no other applications should use the compter’s resources).
How to design your data in a database
Here are some rules for designing data in your database:
“Each column in a single record explains a fact about the key, the whole key, and nothing but the key, so help me Codd“.
- A record should have no columns that depend on another column… in a customer record, you should not have a zip code, because a zip code depends on the city and address. This is called a transitive dependency. First name and last name directly depend on the customer record, so they are allowed.
- Each record should be uniquely identified with an identity column. This identity column will allow you to reference any record without any resultant duplicates.
- Make a separate table for each set of related columns. First name, last name, and e-mail address all would go into the customer table. Product name, description, and price would all go into the inventory table.
2. CRUD
Create - add records to a table
Retrieve - get records from a table
Update - change data in records in a table
Delete - delete records from a table
Now go to W3Schools again, and go through all of the SQL Basic tutorials and complete the test with a 80% or better.