How can I relate custom post types?

There are probably several ways to handle this. I would store the parent product ID for each case study as post meta data for the case study. You can then use a meta query to get all case studies for a product. To display the case studies archive page, add a rewrite endpoint to generate the /productname/casestudies rewrite rules. See this answer for how to load a different template for those requests.