Forums Register Login

Pending status style design

+Pie Number of slices to send: Send
Hello!

I have an already built project (which uses, Spring and JPA). One of the feature allows a user to add a place in the database.

I would like to setup a "pending" state system, that when a user add a new place, this place is added to the database (postgreSQL in my case)
but in a "pending state" and is not actually viewed as a final place. (then an admin will have to approve that place to make it visible to other user)

Is there any mechanism that Spring or JPA offers to archive this?
Or is the only way is to redesign the table and modify all the queries ? (And if so, what would be a good design?, adding an extra column (state) ? or having separates tables etc.. ?

Thank you!
+Pie Number of slices to send: Send
John,
A separate "pending" table is one option. Another is to use a view. You'd still need to modify your existing queries to use the view. Or move the existing data to a new table so the original name can be used as the new view name.
+Pie Number of slices to send: Send
Thank you for replying to my question!

In my question I have simplified my problem.
While I do have a place table I also have tags and pictures(i will this one out for the moment..) that are associated to it
So At the moment I have 3 table (place,tag and pace_tag which link a place to its tags)

The first thing that came to my mind was to duplicate these 3 tables (calling them temporary_place, temporary_tag etc..) when a user add a place I would fill these 3 new table and when then admin approved them I would copy the content to the existing table.
This method as the advantage to avoid having to refactor the all project as I do not touch the existing table structure.. But is this a good design?

If this is a bad idea, and let's say i can afford to refactor the code and queries, what would be an ideal design ?

Jeanne, you are suggesting using views. Could you explain me more in how do you intend using it ? Do you mean creating a new table place with an extra column "state" (which can be an enum or etc..) and creating a view that looks like this?
create view place as select * from place where state='active'; ? (i would have moved all the content of the place table into the new table and name the view place as you suggested )

Thank you
+Pie Number of slices to send: Send
I think either the separate tables or the modifying the queries is best. Which of the two it is would depend on how much existing code you have and whether the pending data shares constraints. If you have unique tag names and the like, there is an advantage to having them in one table.

The views should be a last resort. And yes, your understanding of the view approach is correct.

+Pie Number of slices to send: Send
An other thing I omitted to mention, is that at the moment when adding a new place some calculation is done (on the place and tags).
Because the place will be now in a pending state it makes no sense to include it for calculation.

I actually do like this idea of using views. When you say "last resort" do you mean because it requires to much changes or because it is not commonly done ?
because the view would actually return the exact same structure.


Thank you!
+Pie Number of slices to send: Send
It's not as commonly done. But it is done sometimes. My reason to avoid is that it is another thing to maintain. If I can avoid it and change the real table, I prefer that. It's not bad to use views though. Also, the view approach requires a data migration to new tables. Depending on how much data you have, this might be a pain.
Could you hold this kitten for a sec? I need to adjust this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 575 times.
Similar Threads
Trying to speed up some calculations
Best way to do software encryption?
Architecture Help
Need a better design approach for my requirment
Tutorial PostgreSQL 8.3 on Glassfish V2.1 for ConnectionPool in Netbeans 6.5.1, WindowsXP (Post 3)
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 00:18:17.