Create a Table in the Data Store
Let’s create a table in the Data Store of the Catly project. As mentioned earlier, this table is used to store the original URLs entered by the user along with their short IDs generated by the application. Data from this table is accessed only if it is unavailable in the cache segment.
To create a table:
-
Navigate to the Catalyst CloudScale Data Store component in the Catalyst console. Click Start Exploring.
-
Click Create a new Table.
- Enter the table’s name as “UrlShorten” and click Create.
Create Columns
Let’s now create two columns in the table for the original URL and its short ID.
- Click New Column in the Schema View section for the table.
- Enter the column’s name as “originalUrl”. Select the data type as Var Char and enter the max length as “100”. Enable the Is Unique and Is Mandatory toggle switches.
You can learn about the various data types supported by Catalyst and the other properties of a column from the Data Store help page.
- Click Create.
The column is created.
Let’s create the second column in the same way.
-
Click New Column in the Schema View section for the table.
-
Enter the column’s name as “urlCode”. Select the data type as Var Char and enter the max length as “100”. Enable the Is Unique and Is Mandatory toggle switches.
- Click Create.
The column is created. The short ID or the URL code is generated uniquely by the function for each URL. It is appended after /server/catly, e.g., /server/catly/bXBO2sf8, where bXBO2sf8 is the short ID. As a whole, it is the shortened version of the URL. We will discuss this in detail later.
Both columns are now listed in the Schema View section.
The data is automatically populated in this table each time the user shortens a URL. You can view the records from the Data View section after you shorten a URL.
Last Updated 2024-06-12 17:37:03 +0530 +0530