I am creating a spring boot application. I have tables as Users (primary key userId)
, Policy (primary key poliyId)
, Requested Policies (For User)
and Requested Policies (For Admin)
.
Whenever a user request for policy the details should get added to requestedPolicies (For User) with userId and policyId as foreign key.
[Note : One user can request n number of policies so there will be one to many mapping]
Now Admin can use Requested Policies (For Admin)
table to approve/reject polices of user.
I am a bit confused about how can I achieve this - Which key should I give as Primary key in Requested Policies (For User) and Requested Policies (For Admin) as in Hibernate each table should have at least one primary key ? How can I give One to many or Many to one mapping according to my requirement ?
Please consider my ER diagrams as I am aware it is not appropriate !! Putting it up in post for readers to get clear idea about tables, will make changes later.
- tables shouls have at least one primary key and also mapping between tables is missing
Please suggest to achieve my requirement do I need to add any new tables and how can I map one table to another and what primary key should I give for each table ? Thanks In advance !!