Tuesday, 19 September 2023

Web Tutorial: Oracle APEX Mailing Registration Form (Part 1/4)

Normally, when I begin a web tutorial, I say something like "let's write some code!". Well, today, let's not write some code.

Oracle APEX is a low-code app development platform. My aim today is to create a basic Registration app for a mailing list using this platform. Why? For shits and giggles, I guess. I have no really good reason. In fact, why do I need any reason at all?

With that in mind, you will need to register for an Oracle APEX workspace and log in. Please note that while all these screenshots were taken on Chrome, it was done on my Macbook. It shouldn't make a difference if you use Windows.

Well then, let's jump right in! The features we will use today are mostly found in the first two menu items at the top - App Builder and SQL Workshop.


Click on App Builder. It will bring you to this window where you will click on Create An Application. Pretty intuitive so far, yeah? Don't worry about the rest. We won't be needing it.

Here, enter a name for your application. Ignore everything else and just click on Create Application.

And here, you just created your first app! Click on it...

...and it'll take you to a place where all these pages have been pregenerated for you. Delete as many of them as you can. The only one you might not be able to delete is Page 9999, which is User Login. Oracle APEX is dead set on you having that page whether you use it or not, for reasons I won't go into.

Let's make some pages! Hit the Create Page button and this window will pop-up. There are tons of interesting options, but we are going to go with the basic one, which is the very first one.

Toggle Use Navigation and Use Breadcrumb to Off. We won't be needing those. We'll make our own Login page, which is page id 1. Click on Create Page.

Repeat the process until you have all these pages. Here's a list of pages I created, which we will be working on.
Login (id 1) - A login page for users to enter the app.
Registration (id 2) - A form for users to add themselves to your database.
Update (id 3) - A form for users to update their particulars.
Interests (id 4) - For users to view their Interests and delete them.
Descriptions (id 5) - For users to view their Descriptions and delete them.
Interest (id 6) - For users to add a new Interest.
Description (id 7) - For users to add a new Description.
Update Password  (id 8) - A form for users to update their password.
Logout (id 9) - A page that logs the users out.
Registration Thank You (id 10) - A page that shows a thank you message after registration.


It's time to work on the database. Oracle APEX comes with this nice database management feature. Click on SQL Workshop, the second item in the top menu. You will see these two tables, MAILING_LIST and MAILING_LIST_TERMS, after the next few steps.

From the previous screen, click on Object Browser. This will lead you to this page where the amount of functionality in the left menu is staggering. We will only use the Table function, which is the default page and first option.

On the right panel, click on Table. this will bring up a dialogue where you enter the name of your table. Set Semantics as "Default", and enter whatever you like for Comments.

Here, you can start creating columns for your table. There's a whole bunch of options here, and if you're not new to databases, this should be fairly intuitive.

Now you can go through this process, or you can try another route. Click Cancel, and go back to the main screen. Here, select SQL Commands.

In this screen, you can simply enter in a command to create your tables, and click Run Command. At the end of it, you should have the tables MAILING_LIST and MAILING_LIST_TERMS.

Here's the command for creating MAILING_LIST. The fields are as follows:
EMAIL - This is a string which is the Primary Key for the table. It is used to contact the user.
FIRST_NAME - This string is descriptive, used to address the user.
LAST_NAME - This string is descriptive and optional,
DOB - This is a date field, used to determine the user's age and other information such as Zodiac sign.
GENDER - This is a single character, either "M" or "F".
DAYS - An integer which specifies the number of days between emails.
LAST_SENT - This is a date field whose value tracks when the user was last contacted. Default value is "01-01-1970".
CREATE TABLE "MAILING_LIST" ( "EMAIL" VARCHAR2(100) NOT NULL ENABLE, "FIRST_NAME" VARCHAR2(50) NOT NULL ENABLE, "LAST_NAME" VARCHAR2(50), "DOB" DATE, "GENDER" CHAR(1) NOT NULL ENABLE, "DAYS" NUMBER NOT NULL ENABLE, "PASSWORD" VARCHAR2(100) NOT NULL ENABLE, "LAST_SENT" DATE DEFAULT '01-01-1970' NOT NULL ENABLE, CONSTRAINT "MAILING_LIST_PK" PRIMARY KEY ("EMAIL") USING INDEX ENABLE ) ;


Here's the command for creating MAILING_LIST_TERMS. The fields are as follows:
EMAIL - This string is a Foreign Key to the MAILING_LIST table.
TYPE - This is a string with two possible values - "INTERESTS" or "DESCRIPTIONS".
TERM - This is a non-empty string.
The combination of EMAIL, TYPE and TERM must be unique.

CREATE TABLE "MAILING_LIST_TERMS" ( "EMAIL" VARCHAR2(100 CHAR) NOT NULL ENABLE, "TYPE" VARCHAR2(100 CHAR) NOT NULL ENABLE, "TERM" VARCHAR2(100 CHAR) NOT NULL ENABLE, CONSTRAINT "MAILING_LIST_INTERESTS_PK" PRIMARY KEY ("EMAIL", "TYPE", "TERM") USING INDEX ENABLE ) ;

ALTER TABLE "MAILING_LIST_TERMS" ADD FOREIGN KEY ("EMAIL") REFERENCES "MAILING_LIST" ("EMAIL") ENABLE;



This is just setup so far. We've not done anything terribly exciting yet, but never fear, we're getting to it!

Next

The Registration Process

No comments:

Post a Comment