The simplest way to hook up the two Pi's is to
- have a cat5e/cat6 cross over cable of sufficient length
- configure each Pi to have a unique static IP within the same network by editing the
/etc/network/interfaces
e.g on PI 1
auto eth0
iface eth0 inet static
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.6
on PI 2
auto eth0
iface eth0 inet static
address 192.168.1.6
netmask 255.255.255.0
gateway 192.168.1.5
This will allow each Pi to see the other but not any other device on the subnet
kinda making the setup secure (?) and inflexible (no way to access the db/web server now :( from any other machine)
Alternatively as you are using the Pi3, you can configure the web server PI as an AP (access point) and make the other connect to the first one saving some $ in the process, assuming the distance & bandwidth isnt an issue. You must of course setup the security features as well. This will allow you to access the web server from any wifi enabled device.
Third option is a hybrid of the first two options, the 2 pies talk to each other over ethernet, and external devices connect over wifi with the web server PI acting as AP. If configured as different networks, your application(s) will have be properly configured to accept / connect over specific interfaces or you can setup a bridge to make both the wifi and ethernet into one network.