Reputation: 31647
I am creating new website using JSF 2.0 and MySQL. Below is what I have.
Note Here in each table I am only considering 1-2 fields just for explanation purpose. In real I will have many fields depending on requirement.
I have n number of Applicants.
ApplicantDataTable
+++++++++++++++++++
appId PK
appName
+++++++++++++++++++
Each applicant will have many projects.
ProjectDataTable
+++++++++++++++++++
proId PK
proName
appId FK
+++++++++++++++++++
Each project will have many stages and for each stage I will need to enter data.
stage1datatable
+++++++++++++++++++
stg001id PK
proId FK
stg001name
+++++++++++++++++++
stage2datatable
+++++++++++++++++++
stg002id PK
proId FK
stg002name
+++++++++++++++++++
In applicant screen I will have list of applicants. Once I click on this, I will get list of projects of that applicant. Once I click on that, I will have stage 1 screen and in stage 1 screen, at the bottom i will have link for stage 2, 3, 4, etc.
I see that I will have to take ProjectId & appId through all stages, so I am not sure whether I shall keep bean that will have projectId and appId in session scope? Could some one suggest me how should I structure beans in Java?
Any suggestions would be great.
Upvotes: 0
Views: 141
Reputation: 20691
Ideally, the session scope will work for your use case I.e. store both ids in the session scope, but in reality, it might be overkill. If both ids are going to be processed (and hence be available for re-storing in a scope) you could just keep them in the flash scope. On each destination page, you can access those ids and if you will be needing them on the next request, simply re-store them in the same scope. This way, there will be no wastage. Use the putNow()
method to guarantee the variables are available after the request has been completed.
Unrelated to your question I couldn't help but notice a few concerns in your data model
Why are you duplicating the appName
variable across two tables? Looks like some unnecessary denormalization
Creating a table for each project stage will bring problems in the near future. Unless you're absolutely certain your project stages will never be more than 2 or 3, I'd strongly recommend you consolidate all your project stages into a single table and then add the project_stage_id
as a field in that table. Use a combination of a unique key constraint and a trigger to ensure that duplicates don't occur and that the project stage ids are sequential (if that's a requirement) per project
Upvotes: 1