Connecting a 2x4 and 4x4 post
The following is a fairly classic way to do this.



The 2 by 4s get glued and screwed to the table top with a diagonal cross piece at the corners.

The legs then get placed and screwed or bolted to the diagonal so it gets pulled tight. 

If you use lag screws, or the like, the legs come off pretty easy for storage.