{"id":3103,"date":"2018-08-03T20:55:06","date_gmt":"2018-08-03T08:55:06","guid":{"rendered":"https:\/\/helenanderson.co.nz\/?p=3103"},"modified":"2020-05-14T18:35:33","modified_gmt":"2020-05-14T06:35:33","slug":"relational-database-fundamentals","status":"publish","type":"post","link":"https:\/\/www.helenanderson.co.nz\/relational-database-fundamentals\/","title":{"rendered":"Relational database fundamentals"},"content":{"rendered":"\n

As a\u00a0beginner\u00a0working in relational databases, there are some key concepts<\/a> and fundamentals to understand. These are the things I found most useful when getting started querying databases. Before you get going with writing\u00a0SQL queries<\/a> make sure you have a good grasp of theses basics.<\/p>\n\n\n\n


\n\n\n\n

The Relational Model<\/h2>\n\n\n\n

Data<\/strong> is organised in rows and columns stored in tables.<\/p>\n\n\n\n

Databases<\/strong> hold a collection of data stored in tables.<\/p>\n\n\n\n


\n\n\n\n

Relationship Categories in Databases<\/h3>\n\n\n\n

one-to-one<\/strong>: one husband and one wife<\/p>\n\n\n\n

many-to-one<\/strong>: many students and one school<\/p>\n\n\n\n

one-to-many<\/strong>: one customer and many bank accounts<\/p>\n\n\n\n

many-to-many<\/strong>: many students and many teachers<\/p>\n\n\n\n


\n\n\n\n

Primary Key v Foreign Key<\/h3>\n\n\n\n

To make the most of the database we need to abide by rules to keep data clean, and organised. If we don’t we may as well be storing expensive\u00a0spreadsheets<\/a>,<\/p>\n\n\n\n

To help do this we can use a Primary Key<\/a>. This is a column that best identifies one unique row, and identifies each record as unique, like an ID.<\/p>\n\n\n\n