0
votes

Im brand new to Apex and fairly new to SQL. I made a database that has teachers and students. I want to make an oracle apex application such that when teachers make a new course students can sign up to it. However, since there are many teachers how do i make a form in Apex so that it knows what teacher i am referring to? I wouldnt expect teachers to have to enter their teacher_id (primary key) but dont know what to do.

I made a sequence and trigger so that when a teacher makes a new course listing, a new row goes to the database. What i am stuck on is how apex can identify which teacher is posting that. I have tried to make different users as well but have no idea how to link a teacher user account on apex to a teacher_id (primary key) value in my database so that whenever a specific teacher logs into the apex application, the database knows their teacher_id and uses that automatically whenever a teacher_id is required.

Any form of guidance will be helpful (even a link to a useful youtube video that addresses my problem - I have searched to no avail thus far).

Thanks.

2

2 Answers

0
votes

A simple option would be to identify teachers (and students) by their usernames (they use to log in into your Apex application). In Apex, it is then referenced as :APP_USER variable. As there can't be duplicates (obviously), it will be unique so there won't be any confusion.

So, alter the users table and - along with their ID (which you already have) - add the USERNAME column (or APP_USER, or whatever you want to name it).

0
votes

Based on the information that you have provided, I gather that you have got the tables for the teacher in place. Also, I understand that this table has a primary key of teacher_id.

Now in the course creation form, you can have a field that is mapped to this primary_key column. For display purposes, you can make this field resolve the teacher name (instead of the teacher_id) value. You can achieve this by associating the field with a List of Values (either via a Shared Component).

There are multiple configuration options to achieve this. Here is a link to help you get started on this. Oracle Apex - LoVs

Once, you have the field render user-friendly data, if you would like it to be auto-populated based on the logged in user, you can take the approach that @Littlefoot has suggested above and link the :APP_USER with the teacher_id and use that to set the default value into this field.