Author: plavin
Date: 2007-03-22 21:57:44 +0100 (Thu, 22 Mar 2007)
New Revision: 5509
Log:
Add more sections
Modified:
trunk/userguide/excel-mysql.xml
Modified: trunk/userguide/excel-mysql.xml
===================================================================
--- trunk/userguide/excel-mysql.xml 2007-03-22 20:13:27 UTC (rev 5508)
+++ trunk/userguide/excel-mysql.xml 2007-03-22 20:57:44 UTC (rev 5509)
Changed blocks: 1, Lines Added: 160, Lines Deleted: 2; 5745 bytes
@@ -188,16 +188,174 @@
<title>Designing a Table</title>
- <para></para>
+ <para>
+ We want to import the data directly into a table that mirrors the
+ structure of the spreadsheet. Examining the spreadsheet reveals
+ the following fields and their maximum required lengths:
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ firstname – 50
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ lastname – 50
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ certification – 10
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ expirydate – 10
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ streetaddress1 – 50
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ streetaddress2 – 50
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ city – 50
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ state – 2
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ zipcode – 10
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ certificationnumber – 10
+ </para>
+ </listitem>
+
+ </itemizedlist>
+ </para>
+
+ <para>
+ Creating a table to match these fields is a fairly straightforward
+ matter. Furthermore, by treating all fields as VARCHAR we only
+ need to worry about the order of the fields and their length. We
+ want the right information in the right fields without truncating
+ data.
+ </para>
+
+ <para>
+ Since we are starting from scratch, creating a database is the
+ first step. To do this start the MySQL client and from the command
+ line type:
+ </para>
+
+<programlisting>
+mysql> CREATE DATABASE spreadsheet;
+</programlisting>
+
</section>
<section id="create-table-query-browser">
<title>Creating a Table with Query Browser</title>
- <para></para>
+ <para>
+ As promised we'll use the MySQL Query Browser from now on until
+ we're ready to create a database dump. Query Browser is a fairly
+ intuitive tool but for a quick overview find the documentation at
+ <ulink url="&base-url-docs;"></ulink>.
+ </para>
+ <para>
+ Open the Query Browser specifying <literal>spreadsheet</literal>
+ as the default schema. Enter your credentials and the server
+ hostname and port. When the application opens, you'll find a list
+ of schemata (databases) on the right with the
+ <literal>spreadsheet</literal> database selected. The cursor
+ should be active in the text area at the top of the screen. This
+ text area is used for entering queries, which are executed using
+ the <guibutton>Execute</guibutton> button on the right. If a
+ result set is returned, it shows in the main area in the center of
+ the screen.
+ </para>
+
+ <para>
+ The first thing to do is open a script window — we'll use it
+ as a scratch pad to save copies of the queries we create. Open a
+ script tab by choosing the <guimenu>New Script Tab</guimenu>
+ option from the <guimenu>File</guimenu> menu. After doing this two
+ tabs, one labeled <guilabel>Resultset1</guilabel> and the other
+ <guilabel>New Script</guilabel>, should be visible on the left
+ below the tool bar.
+ </para>
+
+ <para>
+ To create a table, right click the <literal>spreadsheet </literal>
+ database in the <guilabel>Schemata</guilabel> panel and choose
+ <guimenu>Create Table</guimenu> from the pop-up menu.
+ </para>
+
+ <para>
+ This opens the table editor, in the default view with the
+ <guilabel>Columns and Indices</guilabel> tab active. Enter the
+ table name <literal>alldata</literal> in the text box at the top
+ of the table editor. Refer to the values shown in
+ <xref linkend="designing-table"/>, enter a name for each
+ column, choose <literal>VARCHAR</literal> as the data type, and
+ specify a field length. You needn't worry about making any other
+ changes at this point. After all the <literal>alldata</literal>
+ table is only temporary.
+ </para>
+
+ <para>
+ When you are finished use the <guibutton>Apply Changes</guibutton>
+ button. This opens a dialog box showing the SQL code that will
+ execute. Before executing this code, copy it and paste it into the
+ script window. The code should look something like this:
+
+<programlisting>
+CREATE TABLE `alldata` (
+ `lastname` VARCHAR(50) NOT NULL,
+ `firstname` VARCHAR(50) NOT NULL,
+ `certification` VARCHAR(10) NOT NULL,
+ `certificationdate` VARCHAR(10) NOT NULL,
+ `streetaddress1` VARCHAR(50) NOT NULL,
+ `streetaddress2` VARCHAR(50) NOT NULL,
+ `city` VARCHAR(50) NOT NULL,
+ `state` VARCHAR(2) NOT NULL,
+ `certificationnumber` VARCHAR(10) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+</programlisting>
+
+ Right click the <literal>spreadsheet</literal> database in the
+ <guilabel>Schemata</guilabel> pane and chooseRefresh Schemata the
<guimenu>Refresh
+ Schemata</guimenu> option. The newly created table should appear
+ beneath the <literal>spreadsheet</literal> database, ready for imported
data.
+ </para>
+
</section>
<section id="loading-data">
| Thread |
|---|
| • svn commit - mysqldoc@docsrva: r5509 - trunk/userguide | plavin | 22 Mar |