For a comfortable table for the dinette, look at the Lagun system.
https://www.lagunusa.com/Capri has started using them in their campers, and you can see one in action around 1:30 in this video.
https://www.youtube.com/watch?v=Ug_7Qub5mxYAs for replacing your mattress with 4" of memory foam, memory foam is never used as a mattress by itself. so called memory foam mattresses all have 2" or 3" of memory foam bonded on top of 4" to 5" of regular foam.
The Foam factory can custom cut almost anything you want. Take a look at their web site.
https://www.thefoamfactory.com/mattress/mattress.html