Working with Databases
Thank you for joining me for this video. For Servoy University, I’m Bob Cusick. In today’s video, I’m going to show you how you can create databases directly within Servoyian Developer. You can only actually create a database in the bundle post-gres SQL or side-base databases. To do that, come up to your database servers, right-click and say create new database. I’m going to say create a new post-gres SQL database. I’m going to give it a name. We’re going to call this Servoy University demo. All right. Once it’s created. Here it’s showing you all of the connection information for the database that just created. It’s going to be called SU Demo. I’m going to click this close. As you can see, it appears in our list now. I can simply go ahead and right-click it and say create a new table. I’m going to create a table called People. By default, what will make an integer primary key that’s a voice sequence. This will keep counting up 1, 2, 3, 4, 5, 6, 7. You can also go ahead and change the data type, make it a text data type, and you can do something like a UUID generation. But for now, we’ll just keep it as a voice sequence, and we’re going to go ahead and add some columns. I’m going to click Add, and we’ll fast forward when I’m done. So I’ve created a bunch of columns here. Just basic information. First, last address, city, state, zip, and balance do. Now, for each of these columns, I can also have different options. But that was covered in a different sort of a video, so I’m going to just concentrate now on saving this. I’ll just use my demo file, I’ll make a new form, and this is going to come from SU demo. It’s going to be the people, all this name and people. And we’ll go to the next, we’ll add all the columns on here so we can see them. So I just resize the form a little bit to make it easier to see. Now we’ll go ahead and save this form. I’ll go ahead and open it up in the Smart Client. So here you can see, I have my new database that’s got no data into it, but I’m going to just go ahead and import some real quick. So here I went ahead and I imported the thousand rows. Now, I didn’t make all this data up myself. In fact, let me show you this cool site that I used. Well, there’s a site called MakaRoo, and so I just went up here and told it what kind of data I wanted. And what the field name should be, and I got a thousand rows, and I said download, and then I just imported them right into my my server solution. It’s awesome. So here you can see I actually do have a thousand rows of data. Now let’s go ahead and add a couple of different other column types. I’ll go back to Servoy Developer, go back up to my SU demo, open up my people table. Let’s go full view on this. There are other types of columns you can add, including calculation. So let’s go ahead and add one of those. I’m going to add a calculation column, and this is going to be full name. And it’s going to be text and double click, and I get this JavaScript. So I’m going to say return, first name plus a space, plus last name. Let’s save that. Now have a calculation called full name. Let’s go ahead and do an aggregation. I’m going to add a new aggregation. I’m going to say this is going to be balance total. And you have to save it before you can add the specification. So this is going to be a sum of balance do. Let’s go ahead and save that first. Now when I come back to my people form, and I want to add a new field on there, you’ll see that under calculations, I have full name, and under aggregations, I have balance total. So these act just like normal columns, as if I created them in the database editor as normal data columns. So let’s go ahead and add these two columns to the form. All right, let’s go ahead and line them up a little bit there and perfect. All right, now I’ll save this form. All right, so here you can see down at the bottom, I have Bobby Hudson. And this is a sum of all 1,000 records that I’m looking at. So if I change records here, we’ll go do a random one, Sean Stewart. And the balance tool doesn’t change because it’s for the whole set of records. So I’m going to go ahead and perform a find here. And I will say state is California. And so now I have 109 records that were found, and it was how the balance total went to 5,198. Well, there you go. As you can see, it’s really easy to create your own post-grass SQL database or side-based database right from within Servoy developer, add columns, add data, and off you go. I hope you enjoyed this video. Thanks for watching.