entity integrity
This is a topic that many people are looking for. thevoltreport.com is a channel providing useful information about learning, life, digital marketing and online courses …. it will help you have an overview and solid multi-faceted knowledge . Today, thevoltreport.com would like to introduce to you MySQL 11 – Entity Integrity. Following along are instructions in the video below:
welcome back everyone to your MySQL tutorial series im caleb from cables video maker 2 and in this video we are going to start talking about data integrity now there are three categories of data integrity we have entity integrity referential integrity and domain integrity each one of these is going to get its own video so this video is going to talk about entity integrity entity integrity is very simple all it says is that every table needs a primary key when you label something a primary key its automatically going to be unique and not null sorry my dog is feasting right now so if you hear my mom in the background its him I apologize he could not be stopped in addition to this a primary key should never change these are the three things that need to happen for something to be a primary key now theres actually two classifications of primary keys surrogate keys and natural keys surrogate keys are simple theyre just computer generated numbers that have no real world meaning so this is often the ID column in a table natural Keys on the other hand are a little bit harder to work with because these have to
have real-world meaning such as a username or an email or anything that can be unique a onyx were licking the floor now this is not something we tell the database we dont say yo database this is a surrogate key or this is a natural key Onix drink water drink it drink your water these are just these are just terms for us to help understand the different kinds of keys and these are terms people are going to use so you need to understand them why is having a key so important well if you have a table and it doesnt matter what the columns are lets just say thats a row and then we have another row and you can see this is duplicate data and this brings up the question do we have one two entries that are supposed to be different or is this the same entry in there twice its kind of confusing but if we have a primary key we can always assume that there are two different things so for example if we have here 8 and 9 and this would be like the ID we know that this describes an entity and this describes in it
so these are unique check theyre not all because every single one has a value and it has to never change lets see what would happen if it did change lets say thats changed to 19 now were confused because it was 9 and now its 19 so does this 19 refer to a new entity or the same entity with a new ID its confusing if we were following the rules of primary keys and that they never change I would assume that its a new entity and since people assume that we dont want to change our primary keys ever so if youre using a natural key you got to make sure its something thats not going to change and thats kind of hard to figure out like an email thats pretty good because it might not change but what if someone wants to change their email well then they have to change their account information and then its no longer a very good primary key so youd have to restrict people to not being able to update their email well a user name might work because in that situation its not going to change you can restrict people from updating their user
name thats just for like a user table example but youre gonna have those kind of problems with any table that you use natural keys because of that I think more people are starting to use certain keys our surrogate keys better I dont know thats up to you theres downsides and upsides to using either one for example natural keys are much more readable instead of having this number here we could have a string that actually has a value in and this allows you to do less joins which we havent really discussed but essentially when you have multiple tables and you want to get data from both of these tables you have to join them natural Keys allow you to use less joints but in general Im probably going to go with surrogate Keys I think theyre easier to work with and I think theyre more common if you want to use natural Keys Im totally cool with that just make sure that theyre unique not null and they never change ever so yeah everyone thats your introduction to entity integrity if youve enjoyed this video please click like and subscribe and as always I will see you in that next one whoa
tags:
mysql, entity, integrity, data, singularity, plurality, rule of one, table, database, design, primary, key, unique, not null, null, surrogate, natural, caleb…
Thank you for watching all the articles on the topic MySQL 11 – Entity Integrity. All shares of thevoltreport.com are very good. We hope you are satisfied with the article. For any questions, please leave a comment below. Hopefully you guys support our website even more.