1

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 !! ER-Diagram

Shadow
  • 33,525
  • 10
  • 51
  • 64
  • check here please https://www.geeksforgeeks.org/difference-between-primary-key-and-foreign-key/ – muhammed ozbilici Oct 10 '22 at 12:16
  • actually got a probable solution for this. For catering my requirement I need to add one field in requested Policies table something as transactionID and mark it as primary key. – Diptesh karle Oct 12 '22 at 07:07

0 Answers0