#100DaysOfCode in Python Transcripts
Chapter: Days 85-87: Fullstack web apps made easy
Lecture: Data tables
0:00 Our add document form is taking us through the steps here,
0:03 it loads up looking nice.
0:04 We click the button and it validates
0:06 and then down here we'd have to write to do
0:10 create document
0:12 to do go to home or something to that affect.
0:16 Well let's talk about these,
0:17 go home is easy we'll figure that out in a minute.
0:20 Create document, that means we need a database
0:22 and we've talked about SQLAlchemy,
0:24 we've talked about SQLite and
0:27 all of those probably didn't feel super super easy.
0:30 So let's see how it is over here.
0:32 Alright this is probably that
0:33 full stack made easy thing I talked about.
0:36 So we go over here to services,
0:37 expand that out and go to data tables.
0:40 So create a datable service
0:43 and take it back out if we don't like it
0:45 and we're going to add a table.
0:47 Let's create a new table.
0:48 Let's call this categories, lower case.
0:51 And then you define a schema,
0:53 this is just going to have a text column called name
0:57 and it's just going to be text.
0:59 We could add another column like id and so on
1:03 but I think name is actually enough.
1:05 Let's go over here and have
1:06 another table called documents.
1:08 So these are, the documents that our
1:10 little document web app manages.
1:12 Let's give this also a name.
1:14 Give them a date time called created.
1:18 Let's give them a text column called content.
1:23 We could even add, like, a numerical thing for like views,
1:26 how many times they've been viewed or downloaded.
1:28 And now, do this last one that gets pretty interesting.
1:31 Go over here and add link to categories one or many rows.
1:36 How's that?
1:37 Call this category.
1:39 Isn't that awesome?
1:40 So this is your foreign key relationship back over there,
1:43 that's automatically taken care of for us.
1:45 So this is pretty much ready to go,
1:47 let's go and check this part out.
1:48 Let's just add a couple things
1:50 like science
1:53 science news press release documentation.
1:55 So there's a few items.
1:57 Now check this out here, permissions.
2:00 Do you want your server code to be able to get to them?
2:02 Which is pretty safe.
2:06 which your Python code becomes to get access to them.
2:09 This is not super safe.
2:13 in your browser when they view the page
2:15 and potentially, especially if this is edit, mess with it.
2:18 So we're going to say only this, only server modules.
2:22 Okay so server modules can talk to this
2:24 and we can talk to those server modules
2:26 that operate on our behalf.
2:28 We have no documents yet but we have our categories.