So, the symbols that you need to get used to are these arrow types. It's of a similar thing, collection variety, but might have different dimensions to it. So that's kind of the use case for this one is I have heterogeneous data is I guess how I would describe that like data that should live in the same table. This is really nice because we can just put everything in the same table and just express it as JSON. That's going to be just a comment idea of links to a particular type of other common or like Rich Content ID, you can express this in tables but it gets messy and gross and involves a lot of tables. One describes images and then we're going to have to have some sort of like connecting table in the middle. One describes poles one describes videos. Our other option is to have multiple tables. So it's going to have this kind of, it needs a schemaless way of expressing. So these various different types of Rich Content are going to have different kinds of things that are going to associate with it. Or this one's going to be a video and it's going to be URL and it's going to dimension to those videos. This one's gonna be a poll and it's gonna have a question, it's gonna have options. The way that you can do that is with this JSON data type, because these things are gonna be kinda amorphous, right? So if you look down here, I have several of them out here. So imagine you're making a message board anyone had the ability to embed videos embed polls, and embed images, you wanna have this rich content experience. And then the content is a JSON data type and it's not known. In fact, let's go back over here is it It's a unique primary key. And you'll see here it has a Content ID a comment ID, and has content in it. So, one of the In fact, let's go back over here if we look at this you can see we have this rich content table if I only put five records in here so you can if you want to look at it, just say select star from rich content. I don't think this exists in many SQL types. This is, as far as I know, very unique to Postgres. And it kind of allows you to kind of blur that line between what a document is and what a record is across document and SQL based databases. Type is a doesn't have to have a schema so you can put whatever you want in it. So that's the cool thing about this JSON data type. So you can have it this mixed, like schema and schemaless data that lives side by side in the same thing. And then Postgres knows how to query JSON for you. You can actually store JSON as a data type in Postgres. ![]() ![]() And it's kind of a fascinating way they chosen to do it. So one of the really cool features of Postgres is it's kind of ends up being a multi paradigm database because it has the ability to do unstructured data within SQL. ![]() And this is the part that like, these are the reasons why I chose Postgres to teach you versus MySQL and some of those other ones. Postgres stuff, specifically Postgres stuff. So now I've kind of, I've taught you generic SQL stuff. So you can take pretty much all these skills and move directly over to MySQL, probably Oracle and some of these other SQL based databases and just fly with it right. > At this point, we've done pretty extensive querying coverage for SQL. Transcript from the "JSON in PostgreSQL" Lesson
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |