tweaks
authorgamesguru <mathmuncher11@gmail.com>
Tue, 29 Sep 2020 16:34:43 +0000 (12:34 -0400)
committergamesguru <mathmuncher11@gmail.com>
Tue, 29 Sep 2020 19:50:44 +0000 (15:50 -0400)
docs/nt.svg
sql/data/bf_eqs.csv
sql/data/bio_log_entry.csv
sql/data/biometric_log.csv
sql/data/bmr_eqs.csv
sql/data/food_log.csv
sql/data/meals.csv [moved from sql/data/meal_names.csv with 100% similarity]
sql/data/recipe_log.csv [new file with mode: 0644]
sql/functions.sql
sql/import.sql
sql/tables.sql

index ae3aa77a8f3222b257666f90599cfde2e9dd8c25..caa15210e87a2912336415d7aa1f4954e2f6cae6 100644 (file)
@@ -33,8 +33,8 @@
 <polyline fill="none" stroke="black" points="0.26,-852.54 144.26,-852.54 "/>
 <text text-anchor="start" x="7.26" y="-838.94" font-family="Helvetica,sans-Serif" font-size="12.00">id* </text>
 <text text-anchor="start" x="28.26" y="-838.94" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">integer</text>
-<text text-anchor="start" x="7.26" y="-821.94" font-family="Helvetica,sans-Serif" font-size="12.00">bmr_eq </text>
-<text text-anchor="start" x="57.26" y="-821.94" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">text</text>
+<text text-anchor="start" x="7.26" y="-821.94" font-family="Helvetica,sans-Serif" font-size="12.00">name </text>
+<text text-anchor="start" x="46.26" y="-821.94" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">text</text>
 </g>
 <!-- bf_eqs -->
 <g id="node3" class="node">
@@ -44,8 +44,8 @@
 <polyline fill="none" stroke="black" points="580.22,-575.74 724.22,-575.74 "/>
 <text text-anchor="start" x="587.22" y="-562.14" font-family="Helvetica,sans-Serif" font-size="12.00">id* </text>
 <text text-anchor="start" x="608.22" y="-562.14" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">integer</text>
-<text text-anchor="start" x="587.22" y="-545.14" font-family="Helvetica,sans-Serif" font-size="12.00">bf_eq </text>
-<text text-anchor="start" x="624.22" y="-545.14" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">text</text>
+<text text-anchor="start" x="587.22" y="-545.14" font-family="Helvetica,sans-Serif" font-size="12.00">name </text>
+<text text-anchor="start" x="626.22" y="-545.14" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">text</text>
 </g>
 <!-- users -->
 <g id="node4" class="node">
 <text text-anchor="start" x="324.12" y="-679.56" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">real</text>
 <text text-anchor="start" x="274.12" y="-662.56" font-family="Helvetica,sans-Serif" font-size="12.00">goal_bf </text>
 <text text-anchor="start" x="322.12" y="-662.56" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">real</text>
-<text text-anchor="start" x="274.12" y="-645.56" font-family="Helvetica,sans-Serif" font-size="12.00">bmr_id </text>
-<text text-anchor="start" x="320.12" y="-645.56" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">int</text>
-<text text-anchor="start" x="274.12" y="-628.56" font-family="Helvetica,sans-Serif" font-size="12.00">bf_id </text>
-<text text-anchor="start" x="307.12" y="-628.56" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">int</text>
+<text text-anchor="start" x="274.12" y="-645.56" font-family="Helvetica,sans-Serif" font-size="12.00">bmr_eq_id </text>
+<text text-anchor="start" x="341.12" y="-645.56" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">int</text>
+<text text-anchor="start" x="274.12" y="-628.56" font-family="Helvetica,sans-Serif" font-size="12.00">bf_eq_id </text>
+<text text-anchor="start" x="328.12" y="-628.56" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">int</text>
 </g>
 <!-- users&#45;&gt;bmr_eqs -->
 <g id="edge2" class="edge">
 <!-- biometric_log -->
 <g id="node6" class="node">
 <title>biometric_log</title>
-<path fill="none" stroke="black" d="M539.76,-886.43C539.76,-886.43 659.76,-886.43 659.76,-886.43 665.76,-886.43 671.76,-892.43 671.76,-898.43 671.76,-898.43 671.76,-995.43 671.76,-995.43 671.76,-1001.43 665.76,-1007.43 659.76,-1007.43 659.76,-1007.43 539.76,-1007.43 539.76,-1007.43 533.76,-1007.43 527.76,-1001.43 527.76,-995.43 527.76,-995.43 527.76,-898.43 527.76,-898.43 527.76,-892.43 533.76,-886.43 539.76,-886.43"/>
-<text text-anchor="start" x="549.76" y="-987.03" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="13.00">biometric_log</text>
-<polyline fill="none" stroke="black" points="527.76,-977.43 671.76,-977.43 "/>
-<text text-anchor="start" x="534.76" y="-963.33" font-family="Helvetica,sans-Serif" font-size="12.00">id* </text>
-<text text-anchor="start" x="555.76" y="-963.33" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">integer</text>
-<text text-anchor="start" x="534.76" y="-946.33" font-family="Helvetica,sans-Serif" font-size="12.00">guid </text>
-<text text-anchor="start" x="564.76" y="-946.33" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">text</text>
-<text text-anchor="start" x="534.76" y="-929.33" font-family="Helvetica,sans-Serif" font-size="12.00">user_id </text>
-<text text-anchor="start" x="581.76" y="-929.33" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">int</text>
-<text text-anchor="start" x="534.76" y="-912.33" font-family="Helvetica,sans-Serif" font-size="12.00">date </text>
-<text text-anchor="start" x="565.76" y="-912.33" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">int</text>
-<text text-anchor="start" x="534.76" y="-895.33" font-family="Helvetica,sans-Serif" font-size="12.00">notes </text>
-<text text-anchor="start" x="571.76" y="-895.33" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">text</text>
+<path fill="none" stroke="black" d="M539.76,-877.93C539.76,-877.93 659.76,-877.93 659.76,-877.93 665.76,-877.93 671.76,-883.93 671.76,-889.93 671.76,-889.93 671.76,-1003.93 671.76,-1003.93 671.76,-1009.93 665.76,-1015.93 659.76,-1015.93 659.76,-1015.93 539.76,-1015.93 539.76,-1015.93 533.76,-1015.93 527.76,-1009.93 527.76,-1003.93 527.76,-1003.93 527.76,-889.93 527.76,-889.93 527.76,-883.93 533.76,-877.93 539.76,-877.93"/>
+<text text-anchor="start" x="549.76" y="-995.53" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="13.00">biometric_log</text>
+<polyline fill="none" stroke="black" points="527.76,-985.93 671.76,-985.93 "/>
+<text text-anchor="start" x="534.76" y="-972.33" font-family="Helvetica,sans-Serif" font-size="12.00">id* </text>
+<text text-anchor="start" x="555.76" y="-972.33" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">integer</text>
+<text text-anchor="start" x="534.76" y="-955.33" font-family="Helvetica,sans-Serif" font-size="12.00">guid </text>
+<text text-anchor="start" x="564.76" y="-955.33" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">text</text>
+<text text-anchor="start" x="534.76" y="-938.33" font-family="Helvetica,sans-Serif" font-size="12.00">user_id </text>
+<text text-anchor="start" x="581.76" y="-938.33" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">int</text>
+<text text-anchor="start" x="534.76" y="-921.33" font-family="Helvetica,sans-Serif" font-size="12.00">date </text>
+<text text-anchor="start" x="565.76" y="-921.33" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">int</text>
+<text text-anchor="start" x="534.76" y="-904.33" font-family="Helvetica,sans-Serif" font-size="12.00">tags </text>
+<text text-anchor="start" x="564.76" y="-904.33" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">text</text>
+<text text-anchor="start" x="534.76" y="-887.33" font-family="Helvetica,sans-Serif" font-size="12.00">notes </text>
+<text text-anchor="start" x="571.76" y="-887.33" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">text</text>
 </g>
 <!-- biometric_log&#45;&gt;users -->
 <g id="edge3" class="edge">
 <!-- bio_log_entry&#45;&gt;biometric_log -->
 <g id="edge5" class="edge">
 <title>bio_log_entry&#45;&gt;biometric_log</title>
-<path fill="none" stroke="black" stroke-width="0.9" d="M610.92,-1147.95C608.88,-1111.26 605.94,-1058.22 603.59,-1015.84"/>
-<polygon fill="black" stroke="black" stroke-width="0.9" points="606.38,-1015.61 603.14,-1007.78 600.79,-1015.92 606.38,-1015.61"/>
+<path fill="none" stroke="black" stroke-width="0.9" d="M610.92,-1147.95C609.02,-1113.66 606.32,-1065.08 604.06,-1024.27"/>
+<polygon fill="black" stroke="black" stroke-width="0.9" points="606.85,-1024.05 603.61,-1016.22 601.26,-1024.36 606.85,-1024.05"/>
 </g>
 <!-- recipes -->
 <g id="node8" class="node">
 <path fill="none" stroke="black" stroke-width="0.9" d="M521.92,-104.26C511.99,-113.15 501.63,-122.43 491.56,-131.46"/>
 <polygon fill="black" stroke="black" stroke-width="0.9" points="489.43,-129.61 485.34,-137.04 493.16,-133.78 489.43,-129.61"/>
 </g>
-<!-- meal_names -->
+<!-- meals -->
 <g id="node10" class="node">
-<title>meal_names</title>
+<title>meals</title>
 <path fill="none" stroke="black" d="M15.94,-277.55C15.94,-277.55 135.94,-277.55 135.94,-277.55 141.94,-277.55 147.94,-283.55 147.94,-289.55 147.94,-289.55 147.94,-335.55 147.94,-335.55 147.94,-341.55 141.94,-347.55 135.94,-347.55 135.94,-347.55 15.94,-347.55 15.94,-347.55 9.94,-347.55 3.94,-341.55 3.94,-335.55 3.94,-335.55 3.94,-289.55 3.94,-289.55 3.94,-283.55 9.94,-277.55 15.94,-277.55"/>
-<text text-anchor="start" x="30.94" y="-327.15" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="13.00">meal_names</text>
+<text text-anchor="start" x="53.94" y="-327.15" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="13.00">meals</text>
 <polyline fill="none" stroke="black" points="3.94,-317.55 147.94,-317.55 "/>
 <text text-anchor="start" x="10.94" y="-303.95" font-family="Helvetica,sans-Serif" font-size="12.00">id* </text>
 <text text-anchor="start" x="31.94" y="-303.95" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">integer</text>
 <text text-anchor="start" x="57.32" y="-518.98" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">date</text>
 <text text-anchor="start" x="26.32" y="-501.98" font-family="Helvetica,sans-Serif" font-size="12.00">meal_id </text>
 <text text-anchor="start" x="77.32" y="-501.98" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">int</text>
-<text text-anchor="start" x="26.32" y="-484.98" font-family="Helvetica,sans-Serif" font-size="12.00">grams </text>
-<text text-anchor="start" x="69.32" y="-484.98" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">real</text>
-<text text-anchor="start" x="26.32" y="-467.98" font-family="Helvetica,sans-Serif" font-size="12.00">food_id </text>
-<text text-anchor="start" x="74.32" y="-467.98" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">int</text>
+<text text-anchor="start" x="26.32" y="-484.98" font-family="Helvetica,sans-Serif" font-size="12.00">food_id </text>
+<text text-anchor="start" x="74.32" y="-484.98" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">int</text>
+<text text-anchor="start" x="26.32" y="-467.98" font-family="Helvetica,sans-Serif" font-size="12.00">grams </text>
+<text text-anchor="start" x="69.32" y="-467.98" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">real</text>
 </g>
 <!-- food_log&#45;&gt;users -->
 <g id="edge8" class="edge">
 <path fill="none" stroke="black" stroke-width="0.9" d="M163.33,-595.45C193.74,-620.31 229.25,-649.34 260.37,-674.78"/>
 <polygon fill="black" stroke="black" stroke-width="0.9" points="258.97,-677.25 266.93,-680.15 262.51,-672.92 258.97,-677.25"/>
 </g>
-<!-- food_log&#45;&gt;meal_names -->
+<!-- food_log&#45;&gt;meals -->
 <g id="edge7" class="edge">
-<title>food_log&#45;&gt;meal_names</title>
+<title>food_log&#45;&gt;meals</title>
 <path fill="none" stroke="black" stroke-width="0.9" d="M85.98,-458.85C83.62,-424.46 80.93,-385.3 78.93,-356.15"/>
 <polygon fill="black" stroke="black" stroke-width="0.9" points="81.7,-355.61 78.36,-347.82 76.12,-356 81.7,-355.61"/>
 </g>
 <text text-anchor="start" x="272.24" y="-407.55" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">date</text>
 <text text-anchor="start" x="241.24" y="-390.55" font-family="Helvetica,sans-Serif" font-size="12.00">meal_id </text>
 <text text-anchor="start" x="292.24" y="-390.55" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">int</text>
-<text text-anchor="start" x="241.24" y="-373.55" font-family="Helvetica,sans-Serif" font-size="12.00">grams </text>
-<text text-anchor="start" x="284.24" y="-373.55" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">real</text>
-<text text-anchor="start" x="241.24" y="-356.55" font-family="Helvetica,sans-Serif" font-size="12.00">recipe_id </text>
-<text text-anchor="start" x="299.24" y="-356.55" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">int</text>
+<text text-anchor="start" x="241.24" y="-373.55" font-family="Helvetica,sans-Serif" font-size="12.00">recipe_id </text>
+<text text-anchor="start" x="299.24" y="-373.55" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">int</text>
+<text text-anchor="start" x="241.24" y="-356.55" font-family="Helvetica,sans-Serif" font-size="12.00">grams </text>
+<text text-anchor="start" x="284.24" y="-356.55" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00">real</text>
 </g>
 <!-- recipe_log&#45;&gt;users -->
 <g id="edge11" class="edge">
 <path fill="none" stroke="black" stroke-width="0.9" d="M346.03,-347.52C362.48,-315.44 381.25,-278.82 396.6,-248.88"/>
 <polygon fill="black" stroke="black" stroke-width="0.9" points="399.27,-249.81 400.42,-241.41 394.28,-247.26 399.27,-249.81"/>
 </g>
-<!-- recipe_log&#45;&gt;meal_names -->
+<!-- recipe_log&#45;&gt;meals -->
 <g id="edge10" class="edge">
-<title>recipe_log&#45;&gt;meal_names</title>
+<title>recipe_log&#45;&gt;meals</title>
 <path fill="none" stroke="black" stroke-width="0.9" d="M234,-389.83C209.03,-377.62 180.91,-363.87 155.39,-351.4"/>
 <polygon fill="black" stroke="black" stroke-width="0.9" points="156.34,-348.74 147.92,-347.74 153.88,-353.77 156.34,-348.74"/>
 </g>
index 69afd99a75ffb5a11c99f9a2296d34c4fef7d52f..e26f6d0d773ebba365d3556084ea908bdc224de6 100644 (file)
@@ -1,4 +1,4 @@
-id,bf_eq
+id,name
 1,NAVY
 2,3SITE
 3,7SITE
index d4885843c861aac2f879d385c0ce729c0a403d32..5bd12c63d24c41b8bad733c4fce8102a384375a4 100644 (file)
@@ -117,7 +117,9 @@ log_id,biometric_id,value
 33,23,105
 33,24,70
 34,2,69.5
-35,2,68.4
-36,22,66
-36,23,103
-36,24,63
+35,2,66.2
+36,2,68.4
+37,22,66
+37,23,103
+37,24,63
+38,2,65.2
index c1c0066f293c30381ff2d99207070cd05a7beae6..fae6cfee2b9fb3162ece24dea6b26857139e9fce 100644 (file)
@@ -1,37 +1,39 @@
-id,guid,user_id,date,notes
-1,7417256ddb67b9094955de0d653e4b91,1,Sun 28 Jun 2020 02:07:01 PM EDT,exercise
-2,b6dc44db43f823a96bf14d378c4a6e10,2,Sun 28 Jun 2020 02:07:01 PM EDT,exercise
-3,52614b2f5118caa7e1c33f5306ec7eee,1,Sun 28 Jun 2020 02:38:20 PM EDT,
-4,ad4761f8458430bcf894919ffa0a60c8,2,Sun 28 Jun 2020 02:38:20 PM EDT,
-5,ddeda6b7aa0990902c0ff7ca8868c298,1,Sun 28 Jun 2020 10:05:26 PM EDT,exercise
-6,a8093d02eab44586e997b1c6f06024a5,2,Thu 02 Jul 2020 12:12:54 PM EDT,doctor's office
-7,3b621d8701bc0662d8a99c8e255ae2df,1,Sat 04 Jul 2020 03:50:13 PM EDT,
-8,4ff118cdb2f150c6dcaf63ea822133ee,2,Sat 04 Jul 2020 03:54:27 PM EDT,
-9,b12d98910582378fd0bfe513db27dba2,2,Sun 05 Jul 2020 01:30:44 PM EDT,no THC
-10,384729fed3c44775b5a6b83d9df441c1,1,Mon 06 Jul 2020 06:54:49 AM EDT,
-11,a8e6660500e975e6974dc5e5b409674e,2,Sun 12 Jul 2020 12:29:11 PM EDT,THC
-12,89d85a4c81b19ccc5b956574675e303b,2,Sun 12 Jul 2020 02:44:25 PM EDT,THC
-13,64f6ac68c4406082c2bd82f868b4e6ad,1,Sun 12 Jul 2020 02:44:25 PM EDT,THC
-14,d84f359570164f6f634c1f1ee428bf3f,3,Mon 13 Jul 2020 03:30:46 PM EDT,
-15,e43c46b7905f0f43a93a5a32caaf1350,2,Fri 17 Jul 2020 02:02:12 PM EDT,
-16,809ed86cf5f9ca733de44bd4dcafaa34,2,Fri 17 Jul 2020 03:14:37 PM EDT,THC
-17,0c025c05a37fa891ac922990b915008a,1,Fri 17 Jul 2020 03:14:37 PM EDT,
-18,4b7d0b88acd2b28555529185645c022e,2,Sat 08 Aug 2020 01:53:25 PM EDT,
-19,da611fdf349a36fbfabdc39f0b5dd511,3,Thu 27 Aug 2020 12:44:37 PM EDT,
-20,adc9cebc6ce0fe5caba725a20eaf3cf7,2,Fri 28 Aug 2020 03:40:56 PM EDT,
-21,42c2437c8a7d8c6c9df58b874b188bba,1,Fri 28 Aug 2020 03:40:56 PM EDT,1st dabs/2 weeks
-22,7bde0797bc4349091aa0c7c72e09abd2,2,Sun 06 Sep 2020 11:49:47 AM EDT,
-23,b4b5b2a3c5185f787d428db4ae9d4884,1,Sun 06 Sep 2020 11:53:21 AM EDT,
-24,c04eefe3c4c6e167d7bba4bb77d11f60,2,Sat 12 Sep 2020 12:15:53 PM EDT,
-25,e866e51372616e77d110889513ab79e8,2,Sun 06 Sep 2020,
-26,22e182dab0267ceecf537f10d76ccc7f,1,Sun 06 Sep 2020,
-27,2881dc500b6f205b45da19fd60e6464b,2,Sat 12 Sep 2020,
-28,360481648b356ac00ec2227805a02a5b,1,Sat 12 Sep 2020,
-29,f3bf14d7924cd164be8e3cbc56aa795d,1,Sun 13 Sep 2020,
-30,616bca3f62976021cc3b77e91a32de3b,1,Mon 14 Sep 2020,
-31,60a75a93acb0cf77e9f2fe1a05e4d19d,1,Fri 18 Sep 2020 09:04:38 PM EDT,exercise
-32,f4cf78ea8e2c7a03892e4b0268481b59,2,Thu 24 Sep 2020 05:05:51 PM EDT,illness
-33,63239cac4d86f57a69cf9a9c7799a13c,1,Thu 24 Sep 2020 05:05:51 PM EDT,
-34,0ebe7d5f9214f2e62c2952696caaadd9,2,Thu 24 Sep 2020,
-35,67e1a2d244afb9924d1999d792264109,2,Sat 26 Sep 2020,
-36,6f61f3010e4cae1e4d46cc85302ab4d6,2,Sat 26 Sep 2020 11:54:17 AM EDT,
+id,guid,user_id,date,tags,notes
+1,7417256ddb67b9094955de0d653e4b91,1,Sun 28 Jun 2020 02:07:01 PM EDT,exercise,
+2,b6dc44db43f823a96bf14d378c4a6e10,2,Sun 28 Jun 2020 02:07:01 PM EDT,exercise,
+3,52614b2f5118caa7e1c33f5306ec7eee,1,Sun 28 Jun 2020 02:38:20 PM EDT,,
+4,ad4761f8458430bcf894919ffa0a60c8,2,Sun 28 Jun 2020 02:38:20 PM EDT,,
+5,ddeda6b7aa0990902c0ff7ca8868c298,1,Sun 28 Jun 2020 10:05:26 PM EDT,exercise,
+6,a8093d02eab44586e997b1c6f06024a5,2,Thu 02 Jul 2020 12:12:54 PM EDT,,doctor's office
+7,3b621d8701bc0662d8a99c8e255ae2df,1,Sat 04 Jul 2020 03:50:13 PM EDT,,
+8,4ff118cdb2f150c6dcaf63ea822133ee,2,Sat 04 Jul 2020 03:54:27 PM EDT,,
+9,b12d98910582378fd0bfe513db27dba2,2,Sun 05 Jul 2020 01:30:44 PM EDT,no THC,
+10,384729fed3c44775b5a6b83d9df441c1,1,Mon 06 Jul 2020 06:54:49 AM EDT,,
+11,a8e6660500e975e6974dc5e5b409674e,2,Sun 12 Jul 2020 12:29:11 PM EDT,THC,
+12,89d85a4c81b19ccc5b956574675e303b,2,Sun 12 Jul 2020 02:44:25 PM EDT,THC,
+13,64f6ac68c4406082c2bd82f868b4e6ad,1,Sun 12 Jul 2020 02:44:25 PM EDT,THC,
+14,d84f359570164f6f634c1f1ee428bf3f,3,Mon 13 Jul 2020 03:30:46 PM EDT,,
+15,e43c46b7905f0f43a93a5a32caaf1350,2,Fri 17 Jul 2020 02:02:12 PM EDT,,
+16,809ed86cf5f9ca733de44bd4dcafaa34,2,Fri 17 Jul 2020 03:14:37 PM EDT,THC,
+17,0c025c05a37fa891ac922990b915008a,1,Fri 17 Jul 2020 03:14:37 PM EDT,,
+18,4b7d0b88acd2b28555529185645c022e,2,Sat 08 Aug 2020 01:53:25 PM EDT,,
+19,da611fdf349a36fbfabdc39f0b5dd511,3,Thu 27 Aug 2020 12:44:37 PM EDT,,
+20,adc9cebc6ce0fe5caba725a20eaf3cf7,2,Fri 28 Aug 2020 03:40:56 PM EDT,,
+21,42c2437c8a7d8c6c9df58b874b188bba,1,Fri 28 Aug 2020 03:40:56 PM EDT,THC,1st dabs/2 weeks
+22,7bde0797bc4349091aa0c7c72e09abd2,2,Sun 06 Sep 2020 11:49:47 AM EDT,,
+23,b4b5b2a3c5185f787d428db4ae9d4884,1,Sun 06 Sep 2020 11:53:21 AM EDT,,
+24,c04eefe3c4c6e167d7bba4bb77d11f60,2,Sat 12 Sep 2020 12:15:53 PM EDT,,
+25,e866e51372616e77d110889513ab79e8,2,Sun 06 Sep 2020,,
+26,22e182dab0267ceecf537f10d76ccc7f,1,Sun 06 Sep 2020,,
+27,2881dc500b6f205b45da19fd60e6464b,2,Sat 12 Sep 2020,,
+28,360481648b356ac00ec2227805a02a5b,1,Sat 12 Sep 2020,,
+29,f3bf14d7924cd164be8e3cbc56aa795d,1,Sun 13 Sep 2020,,
+30,616bca3f62976021cc3b77e91a32de3b,1,Mon 14 Sep 2020,,
+31,60a75a93acb0cf77e9f2fe1a05e4d19d,1,Fri 18 Sep 2020 09:04:38 PM EDT,exercise,
+32,f4cf78ea8e2c7a03892e4b0268481b59,2,Thu 24 Sep 2020 05:05:51 PM EDT,illness,
+33,63239cac4d86f57a69cf9a9c7799a13c,1,Thu 24 Sep 2020 05:05:51 PM EDT,,
+34,0ebe7d5f9214f2e62c2952696caaadd9,2,Thu 24 Sep 2020,,
+35,7a4692cf15f960c1384210fb477367a9,1,Fri 25 Sep 2020,,gym scale
+36,67e1a2d244afb9924d1999d792264109,2,Sat 26 Sep 2020,,
+37,6f61f3010e4cae1e4d46cc85302ab4d6,2,Sat 26 Sep 2020 11:54:17 AM EDT,,
+38,180eed8bc3094f634895c13331cef858,1,Tue 29 Sep 2020 03:40:37 PM EDT,,no clothes
index fed6d7568bfb511e956bb12eb03aa2d4ca51489e..399d4f871d6e1bf15eea052412cdbc276f493e78 100644 (file)
@@ -1,4 +1,4 @@
-id,bmr_eq
+id,name
 1,HARRIS_BENEDICT
 2,KATCH_MACARDLE
 3,MIFFLIN_ST_JEOR
index 4f8c0602cc02c8b4fdd306f2038057610d706438..c640278bf591762545ddbb8adc1bbaa9f2a9bfbf 100644 (file)
@@ -1,23 +1,23 @@
-id,guid,user_id,date,meal_id,grams,food_id
-1,365e2f316ea39c578a63ec0f59c0d0f0,1,2020-09-20,1,100,13047
-2,71d5d8cbbc591d22cb210ae6323249a1,1,2020-09-20,1,28,1270
-3,295f1cd568fc03b760ff9a3a985c4658,1,2020-09-20,1,55,9038
-4,30bb19b8d57492fee6cb1ebbdc9196a,1,2020-09-20,1,20,11251
-5,d2e64b1da42c2e12bd3dc9f029fb1bb5,1,2020-09-20,1,35,11529
-6,b169e76aa7ccd833a3f7d0e1a5f6935b,1,2020-09-20,1,15,11282
-7,2c53dca9604ea742c39184201d41eed4,1,2020-09-20,1,210,11828
-8,edad78872ae5d7e2a444756a336dce40,1,2020-09-20,1,40,28313
-9,c78bb27a7c756763d10d4bb7f860ba23,1,2020-09-20,1,100,9112
-10,490ffdd0063fcfc79ce5f825a7f2d370,1,2020-09-20,2,140,20137
-11,7fe9a33f24010f1738ddf73010041ced,1,2020-09-20,2,100,5062
-12,a54ddeafde280fd76a0cbbd63b9539e7,1,2020-09-20,2,45,12136
-13,6dfcfbbd5d0cb563343260d287cbdff5,1,2020-09-20,2,50,11821
-14,4704b0288bf626799dc2c09cbb75f28,1,2020-09-20,2,15,44005
-15,7053ec55502f3dccccf16d59c2a38873,1,2020-09-20,3,150,20545
-16,8f7d5caef9dac0d7102a4d90ae9f36c8,1,2020-09-20,3,85,16146
-17,79949cb0b9914d63892b89d91a4a4ad0,1,2020-09-20,3,40,1270
-18,85a4ab5a6da9fa84285dece0f2c7fa2a,1,2020-09-20,3,60,9037
-19,16f98e0382dece4799dd41325b292c70,1,2020-09-20,3,100,15076
-20,bcab83a1676a3ac8f6aadd63dd032e06,1,2020-09-20,3,60,11090
-21,44aa12a8695bfd84a513e24bb65896d9,1,2020-09-20,3,35,11938
-22,252045bc8ba3f133d4006d82a467b053,1,2020-09-20,3,25,11282
+id,guid,user_id,date,meal_id,food_id,grams
+1,365e2f316ea39c578a63ec0f59c0d0f0,1,2020-09-20,1,13047,100
+2,71d5d8cbbc591d22cb210ae6323249a1,1,2020-09-20,1,1270,28
+3,295f1cd568fc03b760ff9a3a985c4658,1,2020-09-20,1,9038,55
+4,30bb19b8d57492fee6cb1ebbdc9196a,1,2020-09-20,1,11251,20
+5,d2e64b1da42c2e12bd3dc9f029fb1bb5,1,2020-09-20,1,11529,35
+6,b169e76aa7ccd833a3f7d0e1a5f6935b,1,2020-09-20,1,11282,15
+7,2c53dca9604ea742c39184201d41eed4,1,2020-09-20,1,11828,210
+8,edad78872ae5d7e2a444756a336dce40,1,2020-09-20,1,28313,40
+9,c78bb27a7c756763d10d4bb7f860ba23,1,2020-09-20,1,9112,100
+10,490ffdd0063fcfc79ce5f825a7f2d370,1,2020-09-20,2,20137,140
+11,7fe9a33f24010f1738ddf73010041ced,1,2020-09-20,2,5062,100
+12,a54ddeafde280fd76a0cbbd63b9539e7,1,2020-09-20,2,12136,45
+13,6dfcfbbd5d0cb563343260d287cbdff5,1,2020-09-20,2,11821,50
+14,4704b0288bf626799dc2c09cbb75f28,1,2020-09-20,2,44005,15
+15,7053ec55502f3dccccf16d59c2a38873,1,2020-09-20,3,20545,150
+16,8f7d5caef9dac0d7102a4d90ae9f36c8,1,2020-09-20,3,16146,85
+17,79949cb0b9914d63892b89d91a4a4ad0,1,2020-09-20,3,1270,40
+18,85a4ab5a6da9fa84285dece0f2c7fa2a,1,2020-09-20,3,9037,60
+19,16f98e0382dece4799dd41325b292c70,1,2020-09-20,3,15076,100
+20,bcab83a1676a3ac8f6aadd63dd032e06,1,2020-09-20,3,11090,60
+21,44aa12a8695bfd84a513e24bb65896d9,1,2020-09-20,3,11938,35
+22,252045bc8ba3f133d4006d82a467b053,1,2020-09-20,3,11282,25
similarity index 100%
rename from sql/data/meal_names.csv
rename to sql/data/meals.csv
diff --git a/sql/data/recipe_log.csv b/sql/data/recipe_log.csv
new file mode 100644 (file)
index 0000000..4e01438
--- /dev/null
@@ -0,0 +1,2 @@
+id,guid,user_id,date,meal_id,recipe_id,grams
+1,6ca4cf9c1b7e7b71ca084d7b704eb29c,1,2020-09-26,1,1,315
index 6a26927c2165f7293ed62b6268a4d4a69259e4d7..e04058761fcf2d9996247b237f3be2f711f07df6 100644 (file)
@@ -3,17 +3,18 @@
 --------------------------------
 
 SELECT
-  date,
   users.name,
-  notes,
+  date,
   (
     SELECT
-      value
+      ROUND(value * 2.204, 1)
     FROM
       bio_log_entry
     WHERE
       biometric_id = 2
-      AND log_id = biometric_log.id) AS weight
+      AND log_id = biometric_log.id) AS weight,
+  tags,
+  notes
 FROM
   biometric_log
   INNER JOIN users ON user_id = users.id
@@ -26,6 +27,44 @@ WHERE
 -- Pulse and blood pressure
 --------------------------------
 
+SELECT DISTINCT
+  date,
+  users.name,
+  tags,
+  notes,
+  (
+    SELECT
+      CAST(value AS int)
+    FROM
+      bio_log_entry
+    WHERE
+      biometric_id = 23
+      AND log_id = biometric_log.id) || '/' || (
+    SELECT
+      CAST(value AS int)
+    FROM
+      bio_log_entry
+    WHERE
+      biometric_id = 24
+      AND log_id = biometric_log.id) AS pressure,
+  (
+    SELECT
+      CAST(value AS int)
+    FROM
+      bio_log_entry
+    WHERE
+      biometric_id = 22
+      AND log_id = biometric_log.id) AS pulse
+FROM
+  biometric_log
+  INNER JOIN users ON user_id = users.id
+  INNER JOIN bio_log_entry ON biometric_id IN (22,
+    23,
+    24)
+    AND log_id = biometric_log.id
+WHERE
+  users.name = 'Mark';
+
 SELECT
   date,
   users.name,
index 46733adcb2e12c917e204ebc3fbc6d071ead6ffc..3dc8803262b671112839495f42a2045c97da820f 100644 (file)
@@ -18,7 +18,7 @@
 
 .import '| tail -n +2 ./data/bmr_eqs.csv' bmr_eqs
 .import '| tail -n +2 ./data/bf_eqs.csv' bf_eqs
-.import '| tail -n +2 ./data/meal_names.csv' meal_names
+.import '| tail -n +2 ./data/meals.csv' meals
 
 .import '| tail -n +2 ./data/biometrics.csv' biometrics
 .import '| tail -n +2 ./data/users.csv' users
@@ -28,6 +28,7 @@
 .import '| tail -n +2 ./data/recipe_dat.csv' recipe_dat
 
 .import '| tail -n +2 ./data/food_log.csv' food_log
+.import '| tail -n +2 ./data/recipe_log.csv' recipe_log
 
 .import '| tail -n +2 ./data/biometric_log.csv' biometric_log
 .import '| tail -n +2 ./data/bio_log_entry.csv' bio_log_entry
index 08fb592e406b708303d1ca6d469b02875e2465ef..14c56b76df95bee13ed586da2c42ec6bc300ac7c 100644 (file)
@@ -29,12 +29,12 @@ INSERT INTO version(version, created, notes)
 
 CREATE TABLE bmr_eqs (
   id integer PRIMARY KEY AUTOINCREMENT,
-  bmr_eq text
+  name text
 );
 
 CREATE TABLE bf_eqs (
   id integer PRIMARY KEY AUTOINCREMENT,
-  bf_eq text
+  name text
 );
 
 --
@@ -53,10 +53,10 @@ CREATE TABLE users (
   act_lvl int DEFAULT 2, -- [1, 2, 3, 4, 5]
   goal_wt real,
   goal_bf real,
-  bmr_id int DEFAULT 1,
-  bf_id int DEFAULT 1,
-  FOREIGN KEY (bmr_id) REFERENCES bmr_eqs (id) ON UPDATE CASCADE,
-  FOREIGN KEY (bf_id) REFERENCES bf_eqs (id) ON UPDATE CASCADE
+  bmr_eq_id int DEFAULT 1,
+  bf_eq_id int DEFAULT 1,
+  FOREIGN KEY (bmr_eq_id) REFERENCES bmr_eqs (id) ON UPDATE CASCADE,
+  FOREIGN KEY (bf_eq_id) REFERENCES bf_eqs (id) ON UPDATE CASCADE
 );
 
 --
@@ -77,11 +77,11 @@ CREATE TABLE biometric_log (
   guid text NOT NULL DEFAULT (lower(hex (randomblob (16)))) UNIQUE,
   user_id int NOT NULL,
   date int DEFAULT (strftime ('%s', 'now')),
+  tags text,
   notes text,
   FOREIGN KEY (user_id) REFERENCES users (id) ON UPDATE CASCADE
 );
 
-
 CREATE TABLE bio_log_entry (
   log_id int NOT NULL,
   biometric_id int NOT NULL,
@@ -90,6 +90,7 @@ CREATE TABLE bio_log_entry (
   FOREIGN KEY (log_id) REFERENCES biometric_log (id) ON UPDATE CASCADE,
   FOREIGN KEY (biometric_id) REFERENCES biometrics (id) ON UPDATE CASCADE
 );
+
 --
 --------------------------------
 -- Recipes
@@ -117,7 +118,8 @@ CREATE TABLE recipe_dat (
 -- Food (and recipe) logs
 --------------------------------
 
-CREATE TABLE meal_names (
+CREATE TABLE meals (
+  -- predefined, includes standard three, snacks, brunch, and 3 optional/extra meals
   id integer PRIMARY KEY AUTOINCREMENT,
   name text NOT NULL
 );
@@ -125,26 +127,25 @@ CREATE TABLE meal_names (
 CREATE TABLE food_log (
   id integer PRIMARY KEY AUTOINCREMENT,
   guid text NOT NULL DEFAULT (lower(hex (randomblob (16)))) UNIQUE,
-  user_id int,
+  user_id int NOT NULL,
   date date DEFAULT CURRENT_DATE,
-  meal_id int,
+  meal_id int NOT NULL,
+  food_id int NOT NULL, -- TODO: enforce FK constraint across two DBs?
   grams real NOT NULL,
-  -- TODO: enforce FK constraint across two DBs?
-  food_id int,
   FOREIGN KEY (user_id) REFERENCES users (id) ON UPDATE CASCADE,
-  FOREIGN KEY (meal_id) REFERENCES meal_names (id) ON UPDATE CASCADE
+  FOREIGN KEY (meal_id) REFERENCES meals (id) ON UPDATE CASCADE
 );
 
 CREATE TABLE recipe_log (
   id integer PRIMARY KEY AUTOINCREMENT,
   guid text NOT NULL DEFAULT (lower(hex (randomblob (16)))) UNIQUE,
-  user_id int,
+  user_id int NOT NULL,
   date date DEFAULT CURRENT_DATE,
-  meal_id int,
+  meal_id int NOT NULL,
+  recipe_id int NOT NULL,
   grams real NOT NULL,
-  recipe_id int,
   FOREIGN KEY (user_id) REFERENCES users (id) ON UPDATE CASCADE,
-  FOREIGN KEY (meal_id) REFERENCES meal_names (id) ON UPDATE CASCADE,
+  FOREIGN KEY (meal_id) REFERENCES meals (id) ON UPDATE CASCADE,
   FOREIGN KEY (recipe_id) REFERENCES recipes (id) ON UPDATE CASCADE
 );