For Scientific Research
Photo: © Stanza. Used with permission.
Today we will be discussing two types of database applications: servers and clients.
We will also introduce a smattering of SQL in our examples.
Image: Seahen / Ch.Andrew / David Vignoni / Wikimedia
Three popular types of database servers are:
- Relational (usually SQL)
- NoSQL ("Not only SQL")
- Object-Relational
SQL = "Structured Query Language"
SQL servers are the most common type of database server.
Some popular SQL server products are:
- MySQL
- PostgreSQL
- Microsoft SQL
- Oracle
We consider any end-user application that can connect to a database server as a database "client".
Examples include:
- Various web applications and frameworks
- Desktop Applications and Mobile Apps
- Data analysis tools and statistics packages
- Scripts and programs and their database libraries
There are three main ways to connect to a database:
- File-based access (SQLite, MDB, CSV)
- Connection to SQL service using "native" client
- ODBC (Open Database Connectivity)
- Using a DSN (Data Source Name)
- Using a connection string ("DSN-less")
- Standard interface to DBs.
- Connect to DB with a DSN.
- DSN = "Data Source Name"
- Requires driver (connector)
- Driver is specific to:
- 32 bit vs. 64 bit
- DB server product
Create a DSN for accessing your SQL database from a Windows PC.
For our exercise, we will connect from the student server.
Create a "user DSN" using the MySQL Unicode Driver.
Go to "Administrative Tools" -> Data Sources (ODBC).
Under the "User DSN" tab click "Add".
From MS-Access, you can link to tables and views from a SQL server.
- Connect DB with a DSN
- Link to DB tables
- Recreate relationships
- Create views, forms, and reports
We can use the same DSN to connect with R.
And we can use the same DSN to connect with Stata.
MySQL WB can connect to the server without needing a DSN.
File-based access does not need a DSN or connection string.
SQL (Structured Query Language) is a language for working with relational databases.
The most common SQL command is a SELECT statement.
Some example queries using SELECT:
- SELECT * FROM table1;
- SELECT column1, column2 FROM table1;
- SELECT * FROM table1 WHERE column1 = "Joe";
- SELECT * FROM table1 ORDER BY column2, column1 ASC;
You can combine WHERE, ORDER BY, and other clauses.
Take a look at your own Firefox history database.
- .header on
- .mode column
- .width 50
- .help
- .tables
- SELECT host, frecency FROM moz_hosts ORDER BY frecency DESC LIMIT 5;
- .quit
Graphic: Mozilla/dietrich
We will discuss your SQL queries.
Graphic: Jagbirlehl / Wikimedia
- Web Applications and Frameworks
- Importing and Exporting SQL Tables
- Using SQL from Another Language
- Project Management and Version Control
|
|
|
- Stata ODBC
- SAS/ACCESS ODBC with MySQL
- Using Microsoft Access as a Front-end to MySQL
- SQL Tutorial and online practice tool
- SQL for Dummies Cheat Sheet
- INNER and OUTER JOIN Queries
- A Visual Explanation of SQL Joins - by Jeff Atwood
- Visual Representation of SQL Joins - By C.L. Moffatt
- Firefox History Sqlite DB
- Cruft
Image: © Nevit Dilmen / Wikimedia
Image: Geek and Poke. Used with permission.