Anvil: Web apps with nothing but Python Transcripts
Chapter: Databases: Storing and querying data
Lecture: Concept: Data tables

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's review really quick.
0:01 So, we saw that we have a database system
0:05 already built into Anvil.
0:06 All we have to do is go and enable the data table's service.
0:10 We saw, in our case, that actually was already done
0:13 or as someone created the user management stuff
0:15 but it could be that you create the tables first
0:18 before you do that, and you have to add it explicitly.
0:21 So here we have a couple of tables that we've created
0:24 averages and measurements, and one called users
0:28 that was the one created by the user service.
0:30 And you can see that we've added a record date
0:32 created date, weight in pounds, resting heart rate.
0:35 Those are standard columns, just direct data
0:38 dates, date times, numbers, and so on.
0:41 But we also had a foreign key relationship over to the user.
0:45 This is the user to whom those measurements belong
0:48 and those have a little bit different
0:49 hyperlink-y looking thing here.
0:51 You saw you can even click it
0:52 and pull up details from the user table.
0:54 That's pretty awesome.
0:55 The other thing we have to look at is the security.
0:58 By default, these are not accessible
1:00 and probably should never be writable from Javascript.
1:04 I don't know, that seems like a reasonable statement.
1:07 We have the forms, that is, the client side Javascript
1:10 cannot directly access this table at all.
1:14 However, the server-side modules
1:16 which are run on the server and are protected
1:18 they can do the validation they need
1:19 and then do whatever they want to talk to the database.
1:21 So we had a server-side module that did two things.
1:25 Added these records here and then we query 'em
1:27 for the given logged in user.
1:30 That's data tables.