How the posts and categories connected each other in wp 4.1.1?

This is not just happening in WordPress 4.1.1, but for all version that I know of from version 3.0 when I started on WordPress

Posts and taxonomy terms are stored in different tables in the db, posts in wp_posts and taxonomy terms in wp_term_taxonomy. To create a relationship between terms and posts, there is another table called wp_term_relationships. This table holds the post ID which relates back to the wp_posts table, and creates a relationship to the appropriate term through the term ID which relates back to the wp_term_taxonomy table.

This is how WordPress knows which terms are connected to which post.

For additional info, check out this article by tutsplus 🙂