Beginning SQL
Beginning SQL Beginning SQL
Now that you know what you want to store, the next step is to divide the data logically to get some idea of your table structure. Dividing Data Logically For now, don’t worry about table names, column names, or data types; rather, just get a rough idea of what table structure you want to use. In a first attempt, you might decide to just lump the whole lot into one huge table, including the following information: ❑ Full name ❑ Date of birth ❑ Address ❑ Email address ❑ Date member joined club ❑ Meeting date ❑ Location ❑ Whether member attended meeting Introduction to SQL If you were to use the preceding example data, your records could look like the following table: Date of Date of Meeting Did Member Name Birth Address Email Joining Date Location Attend? Martin Feb 27, 1 The Avenue, martin@some. Jan 10, Mar 30, Lower West Y 1972 NY com 2005 2005 Side, NY Jane Dec 12, 33 Some Road, Jane@server. Jan 12, Mar 30, Lower West N 1967 Washington net 2005 2005 Side, NY Kim May 22, 19 The Road, kim@mail. Jan 23, Mar 30, Lower West 1980 New Townsville com 2005 2005 Side, NY Y Seems like a reasonable start. However, you do have one problem: How do you store details of more than one meeting? One option would be to simply create a new record for each meeting, something akin to the following table: 29
- Page 46: By the time you’ve completed Chap
- Page 50: Once you download the code, just de
- Page 54: 1 Introduction to SQL A nice, gentl
- Page 58: Figure 1-1 Why and When to Use a Da
- Page 62: Databases are great at dealing with
- Page 66: The SQL language is actually fairly
- Page 70: you wish, and the database system d
- Page 74: A keyword is a word that has some m
- Page 78: Introduction to SQL A perfectly val
- Page 82: Data Type Description Storage Used
- Page 86: The char and varchar data types use
- Page 90: Most RDBMSs handle the most common
- Page 94: To add a new column, use the basic
- Page 100: Chapter 1 30 Date of Date of Meetin
- Page 104: Chapter 1 The Attendance table coul
- Page 108: Chapter 1 34 to thousands of member
- Page 112: Chapter 1 36 Field Name Data Type N
- Page 116: Chapter 1 38 Finally, you need to a
- Page 120: Chapter 1 ❑ Databases are part of
- Page 124: Chapter 2 42 CategoryId Category 1
- Page 128: Chapter 2 44 Member First Last Date
- Page 132: Chapter 2 46 Now Steve’s record l
- Page 136: Chapter 2 This would work fine with
- Page 140: Chapter 2 If you want to delete all
- Page 146: 3 Extracting Information So far you
Now that you know what you want to store, the next step is to divide the data logically to get some idea<br />
of your table structure.<br />
Dividing Data Logically<br />
For now, don’t worry about table names, column names, or data types; rather, just get a rough idea of<br />
what table structure you want to use.<br />
In a first attempt, you might decide to just lump the whole lot into one huge table, including the following<br />
information:<br />
❑ Full name<br />
❑ Date of birth<br />
❑ Address<br />
❑ Email address<br />
❑ Date member joined club<br />
❑ Meeting date<br />
❑ Location<br />
❑ Whether member attended meeting<br />
Introduction to <strong>SQL</strong><br />
If you were to use the preceding example data, your records could look like the following table:<br />
Date of Date of Meeting Did Member<br />
Name Birth Address Email Joining Date Location Attend?<br />
Martin Feb 27, 1 The Avenue, martin@some. Jan 10, Mar 30, Lower West Y<br />
1972 NY com 2005 2005 Side, NY<br />
Jane Dec 12, 33 Some Road, Jane@server. Jan 12, Mar 30, Lower West N<br />
1967 Washington net 2005 2005 Side, NY<br />
Kim May 22, 19 The Road, kim@mail. Jan 23, Mar 30, Lower West<br />
1980 New Townsville com 2005 2005 Side, NY Y<br />
Seems like a reasonable start. However, you do have one problem: How do you store details of more<br />
than one meeting? One option would be to simply create a new record for each meeting, something akin<br />
to the following table:<br />
29