Sie sind auf Seite 1von 49

1

1 1
Using MySQL with LabVIEW Using MySQL with LabVIEW
Presented by Michael Aivaliotis Presented by Michael Aivaliotis
mmWave Integrated Solutions Inc. mmWave Integrated Solutions Inc.
2
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Overall Outline Overall Outline
Database Terminology + Theory Database Terminology + Theory
Introduction to MySQL Introduction to MySQL
Database Design and Creation Database Design and Creation
Connectivity with LabVIEW Connectivity with LabVIEW
Creating Tables Creating Tables
Inserting Data Into Your Tables Inserting Data Into Your Tables
Selecting Data From Your Tables Selecting Data From Your Tables
Advanced Topics Advanced Topics
3
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Relational Database Relational Database
A relational database holds together a A relational database holds together a
bunch of tables made up of columns and bunch of tables made up of columns and
rows, and these tables rows, and these tables relate to each to each
other based on values in a particular other based on values in a particular
column. column.
What is a relational database?
Human thought consists of shortcuts and associations, and this is mimicked by a
relational database. In order to understand something complex or difficult, you
usually break it down into small, related chunks and try to wrap your brain around
each little piece. If you can understand the individual parts and visualize the
relationships, then understanding the whole should be easier. A relational database
is nothing more than a container for those small pieces and relationships.
4
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Relational Example Relational Example
Online Store Catalog Online Store Catalog
Item ID Item ID
Name Name
Colour Colour
Size Size
Price Price
Description Description
Item_id
Item_name
Item_description
Item_id
Item_name
Item_description
master_item
Item_id
Item_colour
Item_id
Item_colour
colours
Item_id
Item_size
Item_id
Item_size
sizes
Item_id
Item_price
Item_id
Item_price
prices
PK
In the real world of application development, one of the more common tasks developers perform is building a catalog for an
online store - consider the store an application that is made up of smaller bits of data. For example, say youre creating a
catalog of sporting goods. Think about what makes up a good catalog. You might come up with the list a similar to the
following:
The item ID
The name of the item
The color of the item
The size of the item
The price of the item
A description of the item
You could enter all of this information in one big table . If you went this a route, you would immediately run into questions like
the following:
How do you enter an item that has multiple colors and sizes?
How do you represent items that are available in multiple sizes as well as multiple colors?
What happens when a blue, extra large sweatshirt is a different price than a red, small sweatshirt?
These questions are just the tip of the iceberg. Without a relational design, you would spend more time answering what if
questions than you would developing the application.
Instead of one large nightmare of a list, you could create several small, related tables:
Master table . Each row contains a unique item ID , item name and general-description.
Colors table . Create one row for each item ID; a sweatshirt that comes in five colors would have five rows.
Sizes table. Create one row for each size available for each item ID; a sweatshirt that comes in three sizes would have
three rows
Price table. One row for each combination of size and color for each item; in sweat shirt that comes in five colors with three
sizes per color would have fifteen distinct entries
All of these tables are related through the use of a keyed value , the item ID.
This process of breaking up a long list of repetitive data into smaller logical structures is called normalization.
5
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Basic Database Elements Basic Database Elements
Database Database
Tables Tables
Records Records
Fields Fields
Keys Keys
Indexes Indexes
Your Database
Table
A B C D E F
Fields
A B C D E F
A B C D E F
A B C D E F
Row 1
Row 2
Row 3
Row 4
Records
It table is the largest of the elements in a database. In the order of creation, a table is the second in
line, after creating the database itself. A database table is not a single, flat file that lives on your file
system. When you work with the database, youre not opening a file and inserting data then closing
the file until you needed again. Instead , you use an interface to the database and issue queries that
manipulate your tables and the information they store. Once tables are created, you can delete them
and alter their structures using queries. Because a table is a container for data, when you drop a
table , you are deleting all the data in it. Similarly, when youalter a table, alterations affect the data
inside it.
Fields give structure to a table and provide a place to store data. Using this spreadsheet analogy, a
field is much like a column. You can have up to 3,398 fields ineach MySQL database table, but If
you do, you might want to take a look at redesigning, or normalizing, your database! You will create
your fields at the same time that you create your tables. In fact, defining your fields is the most
important part of the table creation command. When you define the fields you want to use in your
tables, you need two things: the type and the length. Properly defining your fields is crucial for
creating an efficient database system. If you want to store a four digit number, such as 4,289, in your
table, its best to define that field as a SMALLINT which is meant to hold numbers from zero to
65,535. An example of an incorrect if the mission would be to use the text type, which is meant for
data up to 65,535 characters in length.
A record is an entry in your table. A record is like a row of data, with an entry in each column (field).
Records can beat complete all fields are filled in with accurate data-or incomplete. Incomplete may
or may not mean empty. Depending on how you defined the fields in your table, you can add default
values for empty fields within a record. , Having complete records, whether with actual values or
default values, is important to maintaining the accuracy of your data.
6
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Understanding Keys Understanding Keys
Keys are special Fields that are defined within Keys are special Fields that are defined within
the table creation query the table creation query
Unique Keys Unique Keys
All data in that field for all records must be unique. All data in that field for all records must be unique.
Cannot enter duplicate data for that field. Cannot enter duplicate data for that field.
You can have several unique keys per table. You can have several unique keys per table.
Primary Keys Primary Keys
All data in that field for all records must be unique. All data in that field for all records must be unique.
A Primary Key is the main link between two or more A Primary Key is the main link between two or more
tables. tables.
There can only be one primary key per table. There can only be one primary key per table.
Keys can be very powerful elements of your MySQL tables and records. As you
create well designed databases for use in applications, you will use keys to tie your
tables together. Fields are defined as keys within the table creation query.
Currently supports two types of keys , unique and primary. When you define a field
as unique, you are telling MySQL that no matter what you try, you should never be
able to insert the exact same data in that field for more than one row/record.
A primary key is similar to a unique key in that both types of keys must contain
unique values, but a primary key acts as the main link between two or more tables.
There can be only one primary key per table, but you can have several unique keys.
7
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Primary Key Example Primary Key Example
Automatically incrementing ID field in a table Automatically incrementing ID field in a table
id from orders table is the primary key. id from orders table is the primary key.
This key value is used many times in the This key value is used many times in the
items_ordered table. items_ordered table.
This ties one or more items ordered to a particular This ties one or more items ordered to a particular
order. order.
The line drawn between the tables shows this The line drawn between the tables shows this
relationship relationship
PK=primary key PK=primary key
id
ship_name
ship_address
ship_method
order_date
id
ship_name
ship_address
ship_method
order_date
orders
id
order_id
Item_id
Item_qty
id
order_id
Item_id
Item_qty
Items_ordered
PK
PK
8
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Understanding Indexes Understanding Indexes
Same as Index in the back of a Book. Same as Index in the back of a Book.
Primary key is automatically indexed Primary key is automatically indexed
Can manually add indexes that mimic select Can manually add indexes that mimic select
queries queries
Speed Speed
Selecting data on indexed records return results faster Selecting data on indexed records return results faster
because queries execute faster. because queries execute faster.
Adding records to a table whos value must be indexed Adding records to a table whos value must be indexed
is slower. is slower.
Trade Trade- -off must be made and a decision to add an index off must be made and a decision to add an index
or not. or not.
Database indexes are functionally similar to the index in the back of a book
.indexes help you find things quickly. A field in a table as a primary key, MySQL
automatically adds that information to an index. You can also manually add indexes
to your table, in order to index fields other than the primary key field or to index
fields that provide indexes, which are combinations of one or more fields.
When you select to records that have been indexed by the database, the query will
execute more quickly and therefore return a result more quickly than if the table
has no indexes. Conversely, when you add a record to a table that must index a
value , the query is a bit slower than when an index is not required. Therefore, you
have to decide when it is best to add more indexes and when it is best to just leave
well enough alone. In most cases, you can count on having indexes to tables that
are more read then write, in other words tables whose primary function is to hold
data for display rather than to store data for occasional use.
You can create additional indexes that mimic common select queries. For
example if your application calls for a query that selects all items that are blue (a
color) and large (a size) you can add an index that is a combination of the two fields
color and size . An index on the item ID would not speed up the query, but this
multi-column index would.
9
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Indexing Example Indexing Example
Common practice is to add indexes to Common practice is to add indexes to
tables that are read from more than they tables that are read from more than they
are written to. are written to.
A good table for indexing would be a list of A good table for indexing would be a list of
hardware with specifications. This table hardware with specifications. This table
would be referenced in a test configuration would be referenced in a test configuration
profile. Multiple reads and few writes. profile. Multiple reads and few writes.
10
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Good Database Design Good Database Design
Good database performance relies on a Good database performance relies on a
good database design good database design
Database must be easy to maintain Database must be easy to maintain
Must store limited repetitive data Must store limited repetitive data
More work in the design and planning More work in the design and planning
phase will avoid re phase will avoid re- -work down the road. work down the road.
Key Considerations: Key Considerations:
Investigate table relationships Investigate table relationships
Perform normalization Perform normalization
Good database design is crucial for a high performance application. If the database
doesnt have optimized relationships, normalization , it wont be able to perform as
efficiently as possible.
Beyond performance is the issue of maintenance. Your database should be easy to
maintain. This includes storing a limited amount of repetitive data. If you have a lot
of repetitive data and one instance of that data undergoes a change , that change
has to be made for all occurrences of the data. To eliminate duplication and
enhance your ability to maintain the data, you would create a table of possible
values and use a key to refer to the value. That way, If the value changes names,
the change occurs only once in the master table. The reference remains the same
throughout the other tables.
The benefits of a well planned and designed database are numerous, and It stands
to reason that the more work you do up front, the less you have to do later. A really
bad time for a database redesign is after the public release of an application using it
, and the results are costly.
11
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Relationships Relationships
There are three relationship types There are three relationship types
between tables. between tables.
One One- -to to- -one one
One One- -to to- -many many
Many Many- -to to- -many many
12
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
One One- -to to- -One Relationships One Relationships
Key appears only Key appears only
once in a related once in a related
table table
Example: Each Example: Each
employee is employee is
assigned only one assigned only one
computer computer
EmployeeID
DeptID
FirstName
LastName
ComputerID
EmployeeID
DeptID
FirstName
LastName
ComputerID
employees
ComputerID
ComputerDesc
ComputerID
ComputerDesc
computers
PK
PK
13
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
One One- -to to- -Many Relationships Many Relationships
Key from one table Key from one table
appears multiple appears multiple
times in a related times in a related
table. Most table. Most
common form. common form.
Example: Many Example: Many
employees belong employees belong
to the same to the same
department department
EmployeeID
DeptID
FirstName
LastName
EmployeeID
DeptID
FirstName
LastName
employees
DeptID
DeptName
DeptID
DeptName
departments
PK
PK
14
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Many Many- -to to- -Many Relationships Many Relationships
Primary key from first table appears many times Primary key from first table appears many times
in second table. in second table.
Primary key from second table appears many Primary key from second table appears many
times in first table. times in first table.
These relationships should be converted to One These relationships should be converted to One- -
to to- -Many Many
Example: Example:
A student will take more than one class at a time, and A student will take more than one class at a time, and
a class will always contain more than one student. a class will always contain more than one student.
15
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Many Many- -to to- -Many Relationships Many Relationships
Requires creation of intermediate table, Requires creation of intermediate table,
one that sits between the two tables and one that sits between the two tables and
essentially maps them together. essentially maps them together.
StudentID
FirstName
LastName
StudentID
FirstName
LastName
students
StudentID
ClassID
StudentID
ClassID
Students_classes_map
PK ClassID
ClassDesc
ClassID
ClassDesc
classes
PK PK
16
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Normalization Normalization
A set of rules that will help you optimize A set of rules that will help you optimize
your database design. your database design.
The rules are called The rules are called normal forms. normal forms.
There are 3 normal form levels. Each level There are 3 normal form levels. Each level
has a set of rules. has a set of rules.
First normal form First normal form
Second normal form Second normal form
Third normal form Third normal form
Normalization was developed by an IBM researcher named E F. Codd in the early
1970s . A relational database is merely a collection of data, organized in a
particular manner, and doctor Codd created a series of rules called normal forms
that help Define that organization.
There are two goals of the normalization process: eliminate redundant data (for
example, storing the same data in more than one table) and ensure data
dependencies make sense (only storing related data in a table). Both of these are
worthy goals as they reduce the amount of space a database consumes and ensure
that data is logically stored.
17
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Normalization Normalization Flat Table Flat Table
You start with a single flat table that contains all possible da You start with a single flat table that contains all possible data. Very ta. Very
inefficient and consumes more physical space that it should. inefficient and consumes more physical space that it should.
We will use an example of a DUT test. Each DUT test requires 2 We will use an example of a DUT test. Each DUT test requires 2
power supplies. Each record will contain information on the test power supplies. Each record will contain information on the test, ,
equipment used, DUT information, operator and test status (pass equipment used, DUT information, operator and test status (pass- -
Fail). Fail).
Operator
PowerSupply2
Make_Model_SN
PowerSupply1
Make_Model_SN TestStatus
DUT
SN_PN_LOT
Test
Description
TestDate
Before launching into the first normal form, you have to start with something that
needs to be fixed. In the case of a database, its the flat table. The flat table is like
a spreadsheet many, many columns. All the data you could possibly want is right
there in that flat table. This scenario Is inefficient and consumes more physical
space on your hard drive then a normalized database. Eliminating redundancy is
the first step in normalization, so next we will take this flat table to first normal form.
If this table remained in its flat format, you could have a lot of unclaimed space, and
a lot of space being used unnecessarily. This is not an efficient table design.
18
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Normalization Normalization First Normal Form First Normal Form
Identify each row with a unique column or Identify each row with a unique column or
set of columns (the primary key) set of columns (the primary key)
Each field (column) must contain only one Each field (column) must contain only one
value (be atomic). value (be atomic).
Eliminate duplicative columns from the Eliminate duplicative columns from the
same table same table
Create separate tables for each group of Create separate tables for each group of
related data related data
19
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
TestID
TestDate
TestDescription
OperatorFirstName
OperatorLastName
TestStatus
DUT_ID
TestID
TestDate
TestDescription
OperatorFirstName
OperatorLastName
TestStatus
DUT_ID
Normalization Normalization First Normal Form First Normal Form
Primary and unique Primary and unique
keys were added keys were added
DUT, operator and DUT, operator and
supply information supply information
was made atomic was made atomic
Separate tables were Separate tables were
made for related data made for related data
Tests require multiple Tests require multiple
supplies supplies
DUTs can be tested DUTs can be tested
multiple times multiple times
PK
TestID
SupplyID
SupplyMake
SupplyModel
SupplySN
TestID
SupplyID
SupplyMake
SupplyModel
SupplySN
Test_Supplies
DUT_ID
DUT_SN
DUT_PN
DUT_LOT
DUT_ID
DUT_SN
DUT_PN
DUT_LOT
DUTs
PK
Tests
SupplyIDis a unique key.
20
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Normalization Normalization Second Normal Second Normal
Form Form
Create separate tables for sets of values Create separate tables for sets of values
that apply to multiple records that apply to multiple records
Create relationships between these new Create relationships between these new
tables and their predecessors through the tables and their predecessors through the
use of foreign keys (FK). use of foreign keys (FK).
21
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
DUT_ID
DUT_SN
DUT_PN
DUT_LOT
DUT_ID
DUT_SN
DUT_PN
DUT_LOT
DUTs
Normalization Normalization Second Normal Second Normal
Form Form
SupplyID
SupplyMake
SupplyModel
SupplySN
SupplyID
SupplyMake
SupplyModel
SupplySN
PowerSupplies
PK
OperatorID
OperatorFirstName
OperatorLastName
OperatorID
OperatorFirstName
OperatorLastName
Operators
PK
TestID
TestDate
TestDescription
TestStatus
DUT_ID (FK)
OperatorID(FK)
TestID
TestDate
TestDescription
TestStatus
DUT_ID (FK)
OperatorID(FK)
PK
Tests
TestID
SupplyID
TestID
SupplyID
Test_Supplies
PK
22
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Normalization Normalization Second Normal Second Normal
Form Form
Power supply fields are not related to Power supply fields are not related to
TestID TestID so it should be placed into separate so it should be placed into separate
table. Additional supplies can easily be table. Additional supplies can easily be
added this way. added this way.
Operator table created because it is a Operator table created because it is a
repeating value and possibly very few repeating value and possibly very few
operators operators
23
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Normalization Normalization Third Normal Form Third Normal Form
Remove fields (columns) that are not Remove fields (columns) that are not
dependent upon the primary key. dependent upon the primary key.
The fields of a table should be mutually The fields of a table should be mutually
independent independent
24
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Normalization Normalization Third Normal Form Third Normal Form
SupplyID
SupplyMake
SupplyModel
SupplySN
SupplyID
SupplyMake
SupplyModel
SupplySN
PowerSupplies
PK
DUT_ID
DUT_SN
LOT_ID (FK)
PN_ID (FK)
DUT_ID
DUT_SN
LOT_ID (FK)
PN_ID (FK)
DUTs
OperatorID
OperatorFirstName
OperatorLastName
OperatorID
OperatorFirstName
OperatorLastName
Operators
PK
PN_ID
DUT_PN
PN_ID
DUT_PN
Part Numbers
PK
TestID
TestDate
TestDescription
TestStatus
DUT_ID (FK)
OperatorID(FK)
TestID
TestDate
TestDescription
TestStatus
DUT_ID (FK)
OperatorID(FK)
PK
Tests
LOT_ID
LotNumber
LOT_ID
LotNumber
LOTs
PK
PK
TestID
SupplyID
TestID
SupplyID
Test_Supplies
25
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Normalization Normalization Third Normal Form Third Normal Form
Many Serial Numbers can be tested from the Many Serial Numbers can be tested from the
same Part Number same Part Number
Many Serial Numbers can be tested from the Many Serial Numbers can be tested from the
same Lot Number same Lot Number
This can be applied further to the Power Supply This can be applied further to the Power Supply
table. We can break out the MAKE into a table. We can break out the MAKE into a
separate table etc. separate table etc.
If we add more fields later in the design, we If we add more fields later in the design, we
should go back and review our normal form should go back and review our normal form
conformance from the start. conformance from the start.
26
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
General Design Guidelines General Design Guidelines
Perform In this order: Perform In this order:
Define the objective Define the objective
Design the data structures (tables, fields) Design the data structures (tables, fields)
Discern relationships Discern relationships
Define and implement business rules Define and implement business rules
Create your LabVIEW application Create your LabVIEW application
27
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
What is MySQL? What is MySQL?
MySQL is a relational database management MySQL is a relational database management
system (RDBMS) system (RDBMS)
Main features: Main features:
Speed Speed
Multithreaded server Multithreaded server
Portability (across different OSs) Portability (across different OSs)
Ability to interface with any programming language Ability to interface with any programming language
PHP, Perl, C/C++, J ava, Python, Tcl, ODBC. PHP, Perl, C/C++, J ava, Python, Tcl, ODBC.
Price (open source) Price (open source)
MySQL is the most widely used open source database, with several million users.
In addition to storing all your databases, tables, columns, and rows (and data), my
SQL manages them as one entity . Users are assigned access levels and
permissions, all managed by the MySQL RDBMS. MySQL also logs the actions of
these users and manages the responses to queries.
MySQL Is a multithreaded server, meaning that each time a connection is made , a
new server processes is started. Connections to MySQL do not share processes,
so when one process ends unexpectedly or overloads the server by using an
inordinate amount of memory, just that single processes is shutdown, and the entire
server does not come crashing to a halt. This feature also increases the overall
speed of MySQL.
28
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Licensing Licensing
You can use MySQL free without a license You can use MySQL free without a license
except for the following conditions: except for the following conditions:
Using MySQL as an embedded server in an Using MySQL as an embedded server in an
application that is not licensed under the GNU public application that is not licensed under the GNU public
license license
Developing a commercial application that will work Developing a commercial application that will work
only with MySQL and shipping MySQL as part of the only with MySQL and shipping MySQL as part of the
application application
Distributing MySQL and not providing the source Distributing MySQL and not providing the source
code of MySQL as defined in the GNU public license code of MySQL as defined in the GNU public license
If youre using the open source MySQL from MySQL AB, its Is likely that you dont
need to purchase a license and instead can use MySQL freely for whatever you do.
29
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Installing MySQL Server Installing MySQL Server
Download from: Download from: http:// http://www.mysql.com www.mysql.com/ /
Install Version for your platform (Windows Install Version for your platform (Windows
version discussed here) version discussed here)
This is the server which you can run on This is the server which you can run on
the same machine as your application or the same machine as your application or
can be on a remote (networked) PC. can be on a remote (networked) PC.
After installation execute the following file: After installation execute the following file:
c: c:\ \mysql mysql\ \bin bin\ \WinMySQLadmin WinMySQLadmin
30
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Installing MySQL Server Installing MySQL Server
31
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Running MySQL Server Running MySQL Server
Run the WinMySQLadmin utility. The win MySQL admin application will finish
setting up the necessary files that MySQL needs to run. This step will also create a
MySQL service for NT operating systems and place a stoplight icon in the system
tray indicating MySQLs status. Be sure to remember your MySQL username and
password that is entered here.
32
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Running MySQL Server Running MySQL Server
On winNT, windows 2000 or windows XP., you can start and stop them MySQL
server as a service. By default the MySQL server is configured to start as a service
Immediately upon boot up.
33
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Running MySQL Server Running MySQL Server
Various flavors of MySQL server are Various flavors of MySQL server are
available for windows. If you are running available for windows. If you are running
NT NT\ \2000 2000\ \XP then you should run XP then you should run mysql mysql- -
max max- -nt nt version. version.
You can start and stop the server from the You can start and stop the server from the
command line. See MySQL online command line. See MySQL online
documentation for details. documentation for details.
34
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Installing the Application Driver Installing the Application Driver
MySQL Connector/ODBC MySQL Connector/ODBC (also known as (also known as
MyODBC MyODBC) allows you to connect to a MySQL ) allows you to connect to a MySQL
database server using the ODBC database API database server using the ODBC database API
on all Microsoft Windows and most Unix on all Microsoft Windows and most Unix
platforms. platforms.
This can be downloaded from the same source This can be downloaded from the same source
as the MySQL Server. as the MySQL Server.
This is required to allow LabVIEW to This is required to allow LabVIEW to
communicate with the MySQL server using the communicate with the MySQL server using the
standard Microsoft ADO Interface. standard Microsoft ADO Interface.
35
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Installing the Application Driver Installing the Application Driver
After installation you will see After installation you will see MyODBC MyODBC
listed in your Data Source Selector. listed in your Data Source Selector.
36
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Installing the Application Driver Installing the Application Driver
37
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Using MySQL Control Center Using MySQL Control Center
The MySQL Control Center is a Windows The MySQL Control Center is a Windows
Based GUI application that allows you to Based GUI application that allows you to
easily create databases, manipulate tables easily create databases, manipulate tables
and perform SQL queries. and perform SQL queries.
This tool can be used to test and debug This tool can be used to test and debug
your database and perform simple your database and perform simple
verification tests. verification tests.
38
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Using MySQL Control Center Using MySQL Control Center
39
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Using MySQL Control Center Using MySQL Control Center
Tables can be Tables can be
created with the created with the
interface and interface and
Primary keys Primary keys
can be defined. can be defined.
40
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
LabVIEW code Available LabVIEW code Available
Database Connectivity Toolkit from Database Connectivity Toolkit from
National Instruments contains pre National Instruments contains pre- -built built
VIs that allow simple interfaces to any VIs that allow simple interfaces to any
kind of ADO compliant database. kind of ADO compliant database.
41
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Create Table with LVDCT Create Table with LVDCT
42
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Using ActiveX ADO Using ActiveX ADO
If you want to use plain SQL query If you want to use plain SQL query
language to interface with your MySQL language to interface with your MySQL
database then you can use the ActiveX database then you can use the ActiveX
component called ADO. component called ADO.
This is a high level interface to all This is a high level interface to all
compliant databases on Windows. compliant databases on Windows.
This can be created using an automation This can be created using an automation
reference. reference.
43
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
What is SQL? What is SQL?
SQL is an abbreviation for structured query SQL is an abbreviation for structured query
language . This is the language used to language . This is the language used to
communicate with relational database systems. communicate with relational database systems.
SQL was created at an IBM research center in SQL was created at an IBM research center in
the 70s and was first used by Oracle in 1979. the 70s and was first used by Oracle in 1979.
SQL is now an industry standard is now more SQL is now an industry standard is now more
commonly referred to as ANSI SQL commonly referred to as ANSI SQL
Queries Queries are commands, written in SQL, that you are commands, written in SQL, that you
send to your RDBMS to create databases and send to your RDBMS to create databases and
tables, add and modify records, delete records, tables, add and modify records, delete records,
or extract information to be used in your or extract information to be used in your
application. application.
44
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Using ActiveX ADO Using ActiveX ADO
45
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Create Table with ActiveX ADO Create Table with ActiveX ADO
46
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
LabSQL ADO VIs LabSQL ADO VIs
These are VIs These are VIs
available under the available under the
GNU Lesser Public GNU Lesser Public
License from License from
jeffreytravis.com jeffreytravis.com
Can connect to Can connect to
any database any database
including MySQL including MySQL
47
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
SQL Syntax SQL Syntax
Inserting Data: Inserting Data:
INSERT INTO test3 INSERT INTO test3
( (TestDate,TestDescription,TestStatus TestDate,TestDescription,TestStatus, ,
DUT_ID, DUT_ID, OperatorID OperatorID) VALUES ) VALUES
(1,'HelloWorld',1,1,1); (1,'HelloWorld',1,1,1);
Selecting Data: Selecting Data:
SELECT * FROM Test3 WHERE SELECT * FROM Test3 WHERE TestID TestID <30; <30;
48
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Working with Relational Databases Working with Relational Databases
Working with relational databases requires Working with relational databases requires
manipulation of multiple tables. manipulation of multiple tables.
Before a data record can be inserted into Before a data record can be inserted into
the Tests table we must locate the the Tests table we must locate the
OperatorID OperatorID and the DUT_ID. and the DUT_ID.
After the Tests Table has been updated, After the Tests Table has been updated,
we must then update the we must then update the Test_Supplies Test_Supplies
Table. Table.
49
mmWave Integrated Solutions mmWave Integrated Solutions Presenter: Michael Aivaliotis Presenter: Michael Aivaliotis
Beyond the Presentation Beyond the Presentation
Information is available from thousands of Information is available from thousands of
resources on the internet. resources on the internet.
MySQL and SQL query language is a MySQL and SQL query language is a
mature topic that has many books written mature topic that has many books written
on the subject. on the subject.
Suggestion: Buy two books: Suggestion: Buy two books:
Any Database Design book Any Database Design book
Any MySQL book Any MySQL book

Das könnte Ihnen auch gefallen