Data Base
Data Base
Database
CS314 Software
Engineering
The solution in this course uses a three-tier architecture, with the application
running on a client, services on a webserver, and a separate database server.
1
3/4/22
The server environment varies so your code will need to adapt to three different
run-time scenarios: black-bottle, csu-eid, and csu-guest/external.
Command Line
Interface
with SQL
2
3/4/22
Command line interface queries via mysql such as these will help you explore
the information available in the database without any coding.
3
3/4/22
A query like this combines information from multiple tables and matches
information in multiples columns. London is not just a city in England.
SET @phrase="%london%";
# search query, more columns for plan query
SELECT world.name, world.municipality, region.name, country.name,
continent.name
FROM continents
INNER JOIN country ON continent.id = country.continent
INNER JOIN region ON country.id = region.iso_country
INNER JOIN world ON region.id = world.iso_region
WHERE (country.name LIKE @phrase
OR region.name LIKE @phrase
OR world.name LIKE @phrase
OR world.municipality LIKE @phrase)
LIMIT 100;
A query like this can help you filter the data to just the United States to provide
more meaningful results.
SET @country="United States";
SET @phrase="%london%";
# search query, more columns for plan query
SELECT world_airports.name, world_airports.municipality, region.name,
country.name, continents.name
FROM continents
INNER JOIN country ON continents.id = country.continent
INNER JOIN region ON country.id = region.iso_country
INNER JOIN world_airports ON region.id = world_airports.iso_region
WHERE (country.name LIKE @phrase
OR region.name LIKE @phrase
OR world_airports.name LIKE @phrase
OR world_airports.municipality LIKE @phrase)
AND country.name IN (@country)
LIMIT 100;
4
3/4/22
Java Interface
with SQL
The course Guide contains some simple, standalone Java code to query the
database and print the distinct values from a single column.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;
10
5
3/4/22
The course Guide contains some simple, standalone Java code to query the
database and print the distinct values from a single column.
11
12