public class NamesDataBean extends Object
Constructor and Description |
---|
NamesDataBean() |
Modifier and Type | Method and Description |
---|---|
Map<String,Integer> |
firstNameFrequency()
Returns a map of first names to the number of occurrences of that first name.
|
Map<String,Integer> |
lastNameFrequency()
Returns a map of last names to the number of occurrences of that last name.
|
public Map<String,Integer> firstNameFrequency()
Internally this is a LinkedHashMap
. It only returns at most the top 20 names. Since the entire name is
stored in the database as a single field, a regular expression is used in a view inside the database itself to
count the first names.
The select statement defining the view appears as follows:
SELECT COUNT(FIRST_NAME) COUNT, FIRST_NAME FROM (SELECT REGEXP_SUBSTR(NAME,'^\w+') AS FIRST_NAME FROM PERSON) GROUP BY FIRST_NAME ORDER BY COUNT DESC;
public Map<String,Integer> lastNameFrequency()
Internally this is a LinkedHashMap
. It only returns at most the top 20 names. Since the entire name is
stored in the database as a single field, a regular expression is used in a view inside the database itself to
count the last names.
The select statement defining the view appears as follows:
SELECT COUNT(LAST_NAME) COUNT, LAST_NAME FROM (SELECT REGEXP_SUBSTR(NAME,'\w+$') AS LAST_NAME FROM PERSON) GROUP BY LAST_NAME ORDER BY COUNT DESC;
Copyright © 2015 Joseph Hendrix