Parcourir la source

People and Homes

iyasuwatts il y a 7 ans
Parent
révision
7bcd524ef7
3 fichiers modifiés avec 80 ajouts et 2 suppressions
  1. 57
    1
      README.md
  2. 15
    0
      data-h2.sql
  3. 8
    1
      src/main/resources/schema-h2.sql

+ 57
- 1
README.md Voir le fichier

67
  - `GET` `/people/surname/{lastName}` -- Find all people with a particular last name
67
  - `GET` `/people/surname/{lastName}` -- Find all people with a particular last name
68
  - `GET` `/people/surname` -- Get the result of the surname report above
68
  - `GET` `/people/surname` -- Get the result of the surname report above
69
  - `GET` `/people/firstname/stats` -- Get the report of first name frequencies
69
  - `GET` `/people/firstname/stats` -- Get the report of first name frequencies
70
- 
70
+ 
71
+ 
72
+ 
73
+ 
74
+#### Homes and People 
75
+There is another table in the data base named home that consist of the following
76
+fields:
77
+
78
+| ID | ADDRESS | HOMENUMBER |
79
+|----|---------|------------|
80
+
81
+People in the 'Person' table are able to have a home from the 'Home' table associated with them.
82
+People are mapped to homes through their 'HOME_ID' value which is a foreign key that references the id column in the 'HOME' table
83
+
84
+Add the following homes to the 'HOME' table
85
+
86
+|       Address         |    Home Number    |
87
+|-----------------------|-------------------|
88
+| 36 E. Bayberry Rd.Savannah, GA 31404 | 565-6895 |
89
+| 11 Essex Dr.Farmingdale, NY 11735 | 454-4544 |
90
+| 920 Arlington Street Clifton, NJ 07011 | 985-4515 |
91
+| 234 High Street, PA 19159 | 267-3940 |
92
+
93
+
94
+_You may use the query in the 'data-h2.sql' file to populate the 'PERSON' and 'HOME' table_
95
+
96
+
97
+
98
+Support the following operations:
99
+- Add a "Home" to the database
100
+- Add a person to a home 
101
+- Update an existing 'Home' in the database
102
+- Remove a home from the database
103
+- Remove a list of homes from the database
104
+- Find a home by id
105
+- Find a hom by home number
106
+- Find a home by address
107
+- Find a home by person id
108
+- Generate a list of people that live in a home
109
+
110
+
111
+
112
+
113
+List all of the homes that have more that one person that live there. Group people by the home that they 
114
+live in 
115
+
116
+List all of the people that live a the address _11 Essex Dr.Farmingdale, NY 11735_
117
+ 
118
+Create a query to update a person's home
119
+
120
+Create a query to update a person's 'HOMENUMBER"
121
+
122
+Find the home number of John Smith
123
+
124
+
125
+
126
+

+ 15
- 0
data-h2.sql Voir le fichier

1
+
2
+INSERT INTO HOME (ADDRESS, HOMENUMBER) VALUES ('36 E. Bayberry Rd.Savannah, GA 31404', '565-6895');
3
+INSERT INTO HOME (ADDRESS, HOMENUMBER) VALUES ('11 Essex Dr.Farmingdale, NY 11735', '454-4544');
4
+INSERT INTO HOME (ADDRESS, HOMENUMBER) VALUES ('920 Arlington Street Clifton, NJ 07011', '985-4515');
5
+INSERT INTO HOME (ADDRESS, HOMENUMBER) VALUES ('234 High Street, PA 19159 ', '267-3940');
6
+
7
+
8
+INSERT INTO PERSON ( LAST_NAME, FIRST_NAME, MOBILE, BIRTHDAY, HOME_ID ) VALUES ('Carbral', 'Sheeri', '230-4233', '1970-02-23', 2);
9
+INSERT INTO PERSON ( LAST_NAME, FIRST_NAME, MOBILE, BIRTHDAY, HOME_ID) VALUES ( 'Sharam', 'Raj', '186-5223', '1980-08-31', 3);
10
+INSERT INTO PERSON ( LAST_NAME, FIRST_NAME, MOBILE, BIRTHDAY, HOME_ID)VALUES ('Durand', 'Noelle', '395-6161', '1960-07-06', 1);
11
+INSERT INTO PERSON ( LAST_NAME, FIRST_NAME, MOBILE, BIRTHDAY, HOME_ID)VALUES ('Smith', 'Thomas', '395-6181', '1987-07-06', 1);
12
+INSERT INTO PERSON ( LAST_NAME, FIRST_NAME, MOBILE, BIRTHDAY, HOME_ID)VALUES ('Smith', 'Jane', '393-6181', '1987-12-06', 3);
13
+INSERT INTO PERSON ( LAST_NAME, FIRST_NAME, MOBILE, BIRTHDAY, HOME_ID)VALUES ('Brown', 'Doug', '466-6241', '1954-12-07', 3);
14
+
15
+

+ 8
- 1
src/main/resources/schema-h2.sql Voir le fichier

6
   LAST_NAME VARCHAR2(255) NOT NULL DEFAULT '',
6
   LAST_NAME VARCHAR2(255) NOT NULL DEFAULT '',
7
   MOBILE VARCHAR2(20) NOT NULL DEFAULT '',
7
   MOBILE VARCHAR2(20) NOT NULL DEFAULT '',
8
   BIRTHDAY DATE DEFAULT NULL,
8
   BIRTHDAY DATE DEFAULT NULL,
9
+  HOME_ID SMALLINT DEFAULT NULL,
9
   PRIMARY KEY (ID));
10
   PRIMARY KEY (ID));
10
 
11
 
12
+  ALTER TABLE PERSON
13
+  ADD FOREIGN KEY (HOME_ID)
14
+  REFERENCES HOME(ID);
15
+
16
+
11
 DROP TABLE IF EXISTS HOME;
17
 DROP TABLE IF EXISTS HOME;
12
 
18
 
13
 CREATE TABLE HOME (
19
 CREATE TABLE HOME (
54
 
60
 
55
 );
61
 );
56
 
62
 
63
+
57
 DROP SEQUENCE hibernate_sequence;
64
 DROP SEQUENCE hibernate_sequence;
58
 
65
 
59
-CREATE SEQUENCE hibernate_sequence;
66
+CREATE SEQUENCE hibernate_sequence;