Beginning SQL

Beginning SQL Beginning SQL

marjan.fesb.hr
from marjan.fesb.hr More from this publisher
20.07.2013 Views

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

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

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!