#100DaysOfCode in Python Transcripts
Chapter: Days 85-87: Fullstack web apps made easy
Lecture: Data tables

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Our add document form is taking us through the steps here, it loads up looking nice. We click the button and it validates
0:07 and then down here we'd have to write to do create document to do go to home or something to that affect. Well let's talk about these,
0:18 go home is easy we'll figure that out in a minute. Create document, that means we need a database and we've talked about SQLAlchemy,
0:25 we've talked about SQLite and all of those probably didn't feel super super easy. So let's see how it is over here. Alright this is probably that
0:34 full stack made easy thing I talked about. So we go over here to services, expand that out and go to data tables. So create a datable service
0:44 and take it back out if we don't like it and we're going to add a table. Let's create a new table. Let's call this categories, lower case.
0:52 And then you define a schema, this is just going to have a text column called name and it's just going to be text.
1:00 We could add another column like id and so on but I think name is actually enough. Let's go over here and have another table called documents.
1:09 So these are, the documents that our little document web app manages. Let's give this also a name. Give them a date time called created.
1:19 Let's give them a text column called content. We could even add, like, a numerical thing for like views,
1:27 how many times they've been viewed or downloaded. And now, do this last one that gets pretty interesting.
1:32 Go over here and add link to categories one or many rows. How's that? Call this category. Isn't that awesome?
1:41 So this is your foreign key relationship back over there, that's automatically taken care of for us. So this is pretty much ready to go,
1:48 let's go and check this part out. Let's just add a couple things like science science news press release documentation. So there's a few items.
1:58 Now check this out here, permissions. Do you want your server code to be able to get to them? Which is pretty safe. Or even your client side JavaScript
2:07 which your Python code becomes to get access to them. This is not super safe. People can mess with the JavaScript
2:14 in your browser when they view the page and potentially, especially if this is edit, mess with it.
2:19 So we're going to say only this, only server modules. Okay so server modules can talk to this and we can talk to those server modules
2:27 that operate on our behalf. We have no documents yet but we have our categories.


Talk Python's Mastodon Michael Kennedy's Mastodon