SQL knowledge isn't required to make your appliances do all of the things you need them to, but it might be very useful! Let's take a look through how SQL can enhance your productivity, and how the K1000 database is structured. Learn more: http://dell.to/1GDYpr8
1. Dell World User Forum
UFIL521: KACE and SQL
Brooks Roberts, Learning Development
Michael Klocek, Learning Development
Dell World
User Forum
2. Dell World User Forum
Presenters
• Brooks Roberts
– Dell KACE Learning Development
– 16 Years at Dell
– 4 Years with KACE
• Michael Klocek
– Dell KACE Learning Development
– 11 Years at Dell
– 4 Years with KACE
3. Dell World User Forum
Agenda
• SQL - Why Should I Care
• SQL Table Structure
• SQL Query Structure
• Connecting the Appliance
• Exploring the Database
• Wizards
• The “Easy” Way
5. Dell World User Forum
SQL – Why Should I Care
• What are some things you might use your appliance for?
• What are some things that the appliance stores in SQL?
• What are some daily administrative tasks that interface with the database?
Hint: SQL is everywhere…
6. Dell World User Forum
SQL – Why Should I Care
Things that the K1000 uses SQL for:
Assets
Inventory
Labels
Reporting
Service Desk
What others can you think of?
7. Dell World User Forum
Don’t I Have Wizards For All That Stuff?
You do indeed…
8. Dell World User Forum
Don’t I Have Wizards For All That Stuff?
Then why do I care about learning a new language?
Speed
Accuracy
Efficiency
12. Dell World User Forum
SQL Basics – Table Structure
Database
Tables serve as the building blocks of a database.
13. Dell World User Forum
SQL Basics – Table Structure
TABLE1
ID DATA1 DATA2
Tables consist of columns…
and fields.
Tables will always have a
Primary Key.
Other columns may or may
not be a Foreign Key.
14. Dell World User Forum
SQL Basics – Table Structure
ID DATA1 DATA2 ID DATA1 DATA2
BITS BOBS
15. Dell World User Forum
SQL Basics – Table Structure
ID DATA1 DATA2 ID DATA1 DATA2BITS_ID BOBS_ID
BITS BOBSBITS_BOBS_JT
17. Dell World User Forum
SQL Basics – Table Structure
Group By
Having
Select
From
Where
Order By
Group By is used to condense
results. This is useful for
aggregate functions like Count().
Having is used to further filter
results that have been passed
through a Group By statement.
Select specifies what you want
returned from the query and
the order of the columns.
From indicates what tables will be used in the gathering of
your desired data.
This section includes any joins that you wish to use.
The where clause allows you to filter the data
that is returned against a condition you set.
Order by allows you to sort the
results, by column, in ascending or
descending order.
18. Dell World User Forum
SQL Basics – Table Structure
Group By
Having
Select
From
Where
Order By
Let’s order them the way
they should be written.
21. Dell World User Forum
SQL Basics – Joins
Not all data is stored in one table
Join groups tables together into a virtual table for the purposes of your query.
Many different kinds, but the most basic, and often the most efficient are LEFT JOIN or RIGHT JOIN
• Left join SOFTWARE on MACHINE_SOFTWARE_JT.SOFTWARE_ID = SOFTWARE.ID
22. Dell World User Forum
SQL Basics – Joins
TABLE_1 TABLE_2
1 C
2 D
3 A
4 B
A 11
B 12
C 13
D 14
5 B E 15
ID T2_ID ID DATA
LEFT JOIN
TABLE_2
ON
TABLE_1.T2_ID
= TABLE_2.ID
B 12
23. Dell World User Forum
SQL Basics – Joins
2 D
3 A A 11
D 14
TABLE_1 TABLE_2
1 C C 13
ID T2_ID ID DATA
4 B
B 125 B
B 12
TABLE_3
A 689
T 45
C 168
X 254
ID DATA
R 734
NULL NULL NULL NULL
NULL NULL NULL NULL
NULL NULL NULL NULL
35. Dell World User Forum
KACE Support Portal Migrating to Dell Software Support Portal
• Starting in November, all KACE
Support Portal material will be
migrated to the Dell Software Support
Portal
• All service requests will be submitted
online or by phone
• Same great content
– Knowledge base articles
– Video tutorials
– Product documentation
– JumpStart training
• Check out the Support Portal Getting
Started videos
Editor's Notes
I’m Brooks Roberts and this is Michael Klocek.
Just a couple of notes about myself…
And Mike…
Today we’re going to cover a lot of ground…
We’re going to start off by talking about what SQL is and why you should care.
Table Structure in general
Basic Query structure
How to connect third party applications to the database
How to use the wizards to help you learn
And finally, how to put all that knowledge together and build queries in what I like to call, “The Easy Way”.
So… Why should you care at all?
Well, let’s ask the room….
In general, here’s a short list of important things that the appliance uses SQL for…
What others can you think of?
I know some of you may be asking. Don’t I have Wizards for all of that stuff?!
Indeed you do…
Then why would I bother to learn a new language….?
Three main things drive the need/desire in my mind…
So, for those of you who may not be familiar with SQL in the room, lets start with some basics.
First off… What is SQL?
SQL stands for Structured Query Language.
This is the language that we use to interact with the database…
SQL is a standard and hence, most SQL applications have interchangeable terminology and functions.
At its most basic level, what makes up a database?
Tables… So let’s talk about the structure of tables.
As we said, tables are the building blocks of a database. Without tables, you have a pointless container with a name.
Once you start adding tables to the database, that shell suddenly becomes useful as it houses data.
As databases are made of tables, tables are made of columns and those columns are made of fields.
A Table will always have a primary key…
May or may not have a foreign key…
Now.. The main point of a database, in my mind, is to house relational data. But how do we know what fields in BITS, relates to what data in BOBS? Without relational information we cannot make that assumption. This is where foreign keys come into play in most situations.
One of the things you will notice with the K-Appliances are the lack of foreign keys in most of the major databases.
Instead of foreign keys we use what we call Join Tables.
Throughout the database, you will see tables that end in _JT. Within that same name are two other table names. For example here we have BITS_BOBS_JT which just in its name tells us that it is the Join Table for BITS and BOBS.
BITS.ID relates to BITS_BOBS_JT.BITS_ID and BOBS.ID relates to BITS_BOBS_JT.BOBS_ID
With all three tables we then know how BITS relates to BOBS.
Now that we know how tables relate to each other within the appliance, lets look at how to build queries.
Select Queries are built of the following items.
Select
From
Where
Group By
Having
Order By
Let’s put them all in the correct written order.
Looking at a basic query, you can see the order and that all commands are not necessarily mandatory… some can be inferred and some are only necessary in certain situations.
For example, it is possible to only use Select, although its data set is highly limited without declaring FROM what it is pulling data.
And, If you just want all results, Where is optional…
It takes practice, but you quickly learn what all is necessary and in what circumstances.
Arguably, the most important part of using SQL with a K-Appliance is understanding Joins. Joins make it possible to get that relational data that you are most assuredly after.
We need to understand and utilize joins because…
We use joins to group tables together into large virtual tables for the purposes of the query.
There are many different kinds of joins: Inner, Outer, Cross, Self, etc… The most basic and often the most efficient are Left and Right Joins.
When we left join a table to another table, it maintains the integrity of the data in the table to the left…
For these two tables, the left join would be…
And the following would be the resultant data set.
As you can see, it maintained the data integrity of the table to the left…
If I took that data set and then RIGHT joined another table to it, you will see how a right join will maintain the integrity of the data in the table to the RIGHT.
As you can see… anywhere the data does not match up, the mismatched data falls away and we’re left with null values in those fields.
Okay, we’ve learned the basics and we want to start playing with the database… We need tools!
You can connect to the appliance with all kinds of tools. You can use Query browsers, Microsoft Access and Crystal Reports as a few examples… If you’re more comfortable using one over the other, there’s no problem.
Most Query browsers now days, have native connections that allow you to connect and start querying.
Microsoft applications need a special ODBC connector for MySQL. Crystal reports uses a JDBC connector.
We’re going to be working with two applications that use a native connection, MySQL Workbench and Toad for MySQL.
You can get MySQL Workbench from MySQL.COM.
Scroll down and you’ll see a Downloads (GA) section on the page.
From here, click MySQL Workbench
Then select the Installer file you want.
Toad can be found at http://www.quest.com/toad-for-mysql/
Click download the free trial, enter some personal information and….
Acquire the freeware via the download link.
Before we start exploring the database. Let’s setup and configure both applications.
<setup, configure, explore>