In this video, we design the Jobs table schema using Drizzle ORM with MySQL for a real-world Job Portal application. You’ll learn how employers post jobs by first creating a proper database schema, define ENUMs, and establish a 1:1 relation between jobs and employers, followed by schema generation and migration. This video is part of our Next.js + MySQL Job Portal series. ---------------------------------------------------------------------------------- 📂 Source Code 👉 GitHub Repo: https://github.com/thapatechnical/job-portal-nextjs
⌛TIMELINE⏳ 0:00 Introduction to Job Post Schema 3:40 Creating Jobs Table Schema with Drizzle ORM 11:50 Defining Job–Employer Relation (1:1) 13:35 Generate & Migrate Schema (Drizzle) 14:40 My POV & Best Practices
AI Generated·May contain errors
Hello guys welcome to the MySQL present job portal application Today
is day number 57 and today we are going to see the job post schema
Yes guys today we are going to look at one more layout but this
time it's for our job posting Right now if you look here it's my job
But in reality it's not going to be seen in my job it's going to be seen in post and job
It's not going to be set here you will write the job post here and we will change the title
Everything else is going to stay the same
So if I show you this properly you can see that the form we are
creating Right obviously why do we create any form in the front end
We create it so that whoever is the employer here let's imagine this is
Codifier Private Limited is our institute we have logged in here on this portal
Now what we need is to take online
classes I want to launch an AI related
course I want to take live classes So I need an instructor for that
So what I will do is post a job for an AI course Whoever is
interested instructors I mean upload your resume and apply here
So to post that job I will have to do
something I will have to fill the form
somewhere The job title is AI job course
or AI course The job type will be like this
Freelancing or whatever it is
Type of work is about 1-2 hours a day
Job level is nothing like this
So wherever the location is there will be tax currency minimum and maximum salary
Minimum education whichever instructor wants to apply
Minimum if you have a bachelor's degree or a minimum of 5 years of experience in the company
Expiry date experience requirements
I will write the job description here
What are my requirements what kind of instructor do I want to apply So I need all that
here I need to write that so that the instructor
who reads it will know exactly what I want
What kind of candidate am I looking for
This is what you can see on the front end
Obviously whatever we type here should go to our database
We will display the database data in the front end in the form of proper posts
So before doing all this we have to
create a schema Because we are using diesel
Making a schema means that now you
have tables in your database Right
now we have 4 Although the database
is one but we have made 4-5 tables
One for applicants one for employers one for
users and one for our sessions So here we
have to create another table Which is called
job post And all these fields should come in it
So now we start the video without any delay But before that if
you have not checked
out the previous video yet then please do it
In yesterday's video I showed you how to do it for free Although it's
been months since day 1 Whatever source
code I am sharing with you for free
So that you don't have any problems That's why guys if you
haven' t liked shared and subscribed to
the channel yet then please do it
I am in Nepal right now and it is
very cold here So that's the reason why
you are seeing me like this And I
am making my setup here It is not made yet
So for now you can see that I
have done it in my room That's why
you don't see much clarity Once the
setup is done it will look great
So guys now we create our schema without
any delay And see it is very easy to
create a schema Because we have already
made 4 tables I have already made the schema
As you can see this is the users So making
a schema here means that I am making a
table And whatever you have selected
in your database you will see it as a table
And after that we have to
generate and migrate it So this is
the users You can
see the MySQL table Then we have the sessions
Employers Then we have the applicants So what do we need for
the job post Let's go
down a little I have already written
everything I will explain
it to you don't worry
So that your time is saved and it
is easy for me to explain it to you Here you can
see This is the jobs
table I am saying job
post But our table name will be only jobs
And obviously which
language are we using We are
using MySQL So that's the reason why MySQL table
And then you can see We
have this parenthesis And
your first parameter is the name of your table
And that's your job Comma
After that by giving
a parenthesis Whatever fields you want in
that table You have to
define Like first of all
we all know that id is
very important You know
And that's the primary
key So in jobs
we have this id To which we have given data type int
Auto increment obviously
And then primary key
Then the second is the
title Title is important
If you are posting a job
Then front end development
Or backend
Or full stack developer
Or android developer
This is the title That's why you search
For example if you want to become android developer
Then you will search for
an Android developer If you
are a database specialist Or if
you are searching for a job as a data analyst
There are so many So that 's
the title What should it
be Obviously where care
And the title we have
written here means this
title will be visible
in our database field
and this title as a
property we will use it while coding okay its
length is 255 maximum
And not null
Basically it should not be null
Now the second most important thing is
The jobs
Why
Why do we need this table
We need this table
So that all the employers
Can post jobs
Means
Our jobs table
And our employers table
Are connected
But
When we talk about SQL
Connection means relationships
So our jobs table
And our Employers
table What is the
relationship between
these two And that 's
We have to define
it like this One
job must belong
to one employer Right
One employer can
have multiple jobs Right One
company Like my codifier I will not say just
one AI course I am doing
a full stack myself
Then we do a Python
course We do a MySQL course
So employers can post multiple jobs
But one job
Will be related to only one employer
Means one job must belong to one employer Okay
So for that
Employer ID
This is the field name
Basically property
And here is the field
name In this way Int obviously And not null
This should not be
null Where are we taking the reference
from In jobs This field
Where are we getting the reference from
We are getting the reference from
The employers table
Dot ID
So the employers table's ID
Will match with this
And this property is optional
Which is also importa
And that is
onDeleteCascade Means this is yesterday
Like these jobs Thapa
technical uploaded I mean
posted Now what happened
is Thapa technical's
requirement Completed Completely
In a different platform
He moved
He deleted his account
So the employer
If he is not there
So his job post
What will we do by
keeping it If we don't want it then it is wrong
So that's the main
part If the employer
goes the job post which
he has posted will be automatically
deleted Okay Then the
description Now
whichever job post you do
So it needs some description
So you will
write It should not be null It should be tax
It can be tax
Hashtag AI
Hashtag AI course
Hashtag codifier
Understand
Something like this
Minimum salary How much will you offer
Maximum salary
Salary currency
The currency of the salary
In what form
Like the US dollar
Whatever it may be
Now here's something
to consider
Here we will use a
different data type
That's MySQL
enum Okay
And here This is the field's name And this
is the values Which
we are going
to get
So basically This is enum
Means whenever
there is
MySQL currency
One second Currency
See this So what you are
seeing now So
here we have
Options means
Whatever currency I am
talking about
About money
It can be
One of these
Only other than this
it can't be
other than
this so these are values we
have to select
one of these
so salary currency now you are
thinking what is salary currency so basically
We have made a different
file which we
have already
DefinedCreated
And that is
The constant See
My always
main For you
is Go
to A to Z
Detail And
that is
This par
Configuration In configuration
The constant file
We have made
it And now
In the result
folder The
schema ts
There We are
working Right
now If you want to
create Any new table It works
In this Okay
So right now I am in constant Here
You can
already see
That's the
salary Underscore currency
Inside Array And these
are the values And
as const Means The
values Which
you can see
It will be
read only
and type
script will
treat it as a value
rather than
a string
okay so everywhere
you can see as const you know
when you are working on
type scrip
So we have a salary
period I
thought to show you the constant let
me show you what we are
seeing here The salary
period Do you want to
take it on an
hourly basis
or on a monthly basis
Whether on a yearly
basis or not
it doesn 't
matter If you want to take it I as an
employer if
I am
posting a job it is on me that I will give you
as hourly or monthly
Or yearly
Okay
Then The type of job
Remote Or
hybrid Or on-
site The
type of
work How
you want
to do Full-time
Part-time You want to
do Right
Then The
level of the
job We have
kept Multiple
options But
Okay Internship
Entry level
Junior mid
senior You can
see In this
way Then Minimum
education None High
schoolUndergraduate
Master or PhD
So all these
Constant Fields in
which we
have an array
in which
values are there and
basically anoms are there Okay We
treat it as
anom That one of
these you
can selec
So salary
period We have
seen Location
Obviously Your locations
Not your
locations Basically The
job we are posting For example Right
now I will
write Pokhara The type of
job Right This Work type
Job type
And job level
We have already seen
In constant
ExperienceObviously
Then minimum education
We have just seen
Is featured
Many times
What happens We have some
Posts
Some job posts
Which we want to feature
So this is
that Expired Obviously
Like My requirement
is Before new
year Before
31st December
Before I need two
Candidates I need two
instructors So my last
date Yesterday
31st December
In first gen I don't
want you to
see the job
post because
the last
date was
31st December so that
expiry date was deleted
add created updated
add so you
can see it is automatic
You will know It is deleted Add So
this was
our schema And just
In drizzle
By writing
this much You have
defined The
relation You
have to tell it
Properly And
don't worry
I will
show you how it is right
So whenever
you define
a relation
between two
tables in
drizzle it
happens first
you have
to type
the keyword then
we have this
parenthesis in it firs
The name of the table
One second I will
remove it See The name of
the table This is
the name of the table
Obviously it is the
table of jobs Then comma We
have this callback function In
We have a helper
function Basically it is
restructuring One And
many Mostly
So this is a
one to one
relationship it's a one
Then callback
function In parenthesis
Again You can see
What we have passed
is the objec
The name of the relation
You are giving the name And that's the
Employer We have left it
After that
The type of the relation
What is it
It's again one
Means One job
Belongs to one employer SimpleThen
Other table
Here already
Your table is
Jobs The relation of
Jobs table
With whom We have
to make it
With employer's table
What is the relation
Between them
One to one Right And when you
are doing one
to one You
have to pass
an optional property
Optional values You
have to pass
And that's
I am passing an object
There are two fields
I mean two properties One is fields
the second
is reference
So fields
means your current table in
it which field you are
connecting with which field
of the other
table Right
You are making
a relation
So in my fields
Current table
Which is Employer
ID I want to
reference Employer 's
table Employer's ID So in
this way We define
Relations This is done So
once You are done
You don't have
to do anything
You come here
Right Close it So
You have
to generate
it first
NPM Learn db
And then We need
to generate Right Because
whenever you
change the
schema we have
to generate
it first
I have
generated it If I refresh It
Here You can 't
see The
table Which
we just
Created So
to reflect That We have
to
Migrate db
Migrate I hope you can see
So the moment
You write these two commands
So 3 2 1
And boom
So my work is done
Now the moment
I refresh
And this is it Now we have One
more new
table In our job
portal Application And
that's the Jobs
table See ID title employee
In this way So yeah guys
This is it
I hope you will Like
this video And this
layout We
will fix it
Don't worry Right But
yes It was in your
mind When
will it start
Because I
was A little
outside Not outside
I have
come here to
Nepal So
it is taking
time to set everything
up But once it is properly set up
then we will be regular
A lot is left right
We will do awesome
In 2026 This is the
guarantee Don't worry
So our Jobs table
Is ready
Tomorrow We
will do Validation Then
we will do
Everything Don't worry
Step by step We
have to wal
We have to
create it will be fun
right you
just be with me you
just practice
it and
if someone thinks
there should be more
things in this or we
can keep its
values more
Whatever it
is Comment
to me And tell me
I will
be very happy
I have done I think You don't have Any
problem Right So yeah
guys This is it
That 's all for this video
I want to tell If
you have any doubt Do
comment And if you want To support me And if
you are watching
Please like the video
Share it with your
friends And
if you haven'
Subscribed to this channel Please do it
See you in the
next video Till then guys Thank you so
much Take care