Gen AI Powered SQL For Business Analytics 2026 | Learn SQL With Gen AI | Simplilearn
Chapters25
Overview of the AI powered SQL course and how generative AI enhances data analysis and decision making.
Gen AI Powered SQL for Business Analytics 2026 blends SQL skills with generative AI to speed up data analysis, automate tasks, and drive real-time decisions.
Summary
Simplilearn’s Gen AI Powered SQL for Business Analyst course, led by a founder-level overview of SQL with AI, teaches you to harness AI tools to clean, query, and analyze business data. The instructor emphasizes that SQL remains the backbone for data analysis, but AI adds automation, faster optimization, and real-time insights. You’ll start with SQL basics, learn to connect to diverse data sources, and then dive into numbers, strings, and data types to write efficient queries. A core thread is applying AI to speed up data analysis and automate repetitive tasks, all while solving real-world, large-scale datasets. The course wraps with real-world projects, building complex queries and making data-driven business decisions. By the end, you gain solid SQL proficiency plus AI-powered tooling to make workflows smarter and faster. If you’re exploring business analysis, this course positions you for roles that demand hands-on SQL plus AI capabilities, including certification prep aligned to CBA/CCBA. Expect hands-on labs, industry projects, and live expert sessions.
Key Takeaways
- Atomicity guarantees that a transaction is all or nothing: either the entire transfer happens (debit and credit) or none does, ensuring financial accuracy.
Who Is This For?
Essential viewing for business analysts and data professionals who want to pair SQL with Generative AI to accelerate data-driven decisions and automate analytics workflows. It’s especially valuable for learners aiming to leverage tools like PowerBI, Excel, and SQL in AI-enhanced analyses and for those preparing for CBA or CCBA certifications.
Notable Quotes
"What is the primary purpose of SQL in data analysis? B to manage and query data in databases?"
—A foundational question used to introduce SQL’s role as the language to interact with databases.
"Atomicity says it ensures that transactions are executed in all or nothing manner."
—Defines a core database guarantee essential for reliable money transfers and many business operations.
"SQL is a language to talk to the DBMS, so you must speak SQL to instruct the database management system."
—Explains the interaction model between SQL and database management systems.
"Relational databases are strict, table-based structures with primary and foreign keys."
—Introduces core database concepts that underlie SQL querying and data integrity.
"AI tools can speed up data analysis and automate tasks, making your workflow smarter and faster."
—Highlights the course’s AI-driven advantage for analytics pipelines.
Questions This Video Answers
- How does atomicity differ from durability in database transactions?
- What is the difference between relational and NoSQL databases, and when should you choose each?
- How can window functions complement group by in SQL queries?
- What are common SQL data types and constraints, and how do you decide when to use them?
- How can AI be integrated into SQL workflows for real-time analytics?
Gen AI Powered SQLSQLGenerative AIOLTPRelational DatabaseDBMSSQL FunctionsWindow FunctionsNoSQLGraph Database
Full Transcript
What if you could not only master SQL but also leverage the power of AI to make smarter and faster business decisions? Well, this course is all about taking your SQL skills to the next level and it's powered by generative AI. Hey everyone and welcome to the Genai powered SQL for business analyst course by simply learn. So in today's world, businesses are sitting on massive amounts of data and it's only valuable if you can unlock the insights hidden within it. So SQL is one of the best tools for working with data. And when combined with the power of AI, it opens up a world full of possibilities.
So this course is designed to teach you how to efficiently analyze business data using SQL with AI tools that can help you automate tasks, optimize queries, and generate insights in real time. And in this course, here's what we will cover. Firstly, we will start with the basics of SQL and understand how it fits into the data analysis for business. Next, we dive into how to connect to different data sources, clean your data, and prepare it for analysis. Then, let's explore how SQL functions work with numbers, strings, and data, and write more efficient queries. After that, we will show you how to leverage the power of AI to speed up data analysis, automate tasks, and get better insights from your data.
Finally, we'll put everything together by working through real world examples, building complex queries, and running them against large data sets, all while making datadriven business decisions. And by the end of this course, you will have the SQL skills that you need to succeed as a business analyst with the added bonus of an AI powered tools that makes your workflow smarter and faster. So, if you're ready to unlock the potential of your data, let's get started. Also, here's a quick information. If you are interested in boosting your career in business analysis, do not forget to check out our AI powered business analyst course.
This course is perfect for professionals looking to enhance their skills with the latest tools like PowerBI, Excel, and SQL all while gaining hands-on experience with real world projects. So, you will also learn how to leverage generative AI for smarter, faster decision-m. Our program is IIBA and Babok V3 align and it helps you prepare for certifications like CBA and CCBA. You will engage with 10 plus industry projects, 40 plus practical activities, and benefit from live online sessions led by experts. Plus, with Simply Learn's job assist, you will get the support that you need to land your next big role.
So, before we dive into the world of SQL and AI, let's test your knowledge. Here is a simple question to get you thinking. What is the primary purpose of SQL in data analysis? Is it A to create websites or is it B to manage and query data in databases? C to design mobile apps or is it D to edit photos? Take a moment to think about it and when you're ready let's jump into the course. So database is nothing but it is a structure which can store the data and definitely store the data digitally or electronically because see when I talk about the wardrobes you have the wardrobes at your home.
So uh you you get to see the physical wardrobe but here in the computer world everything is digital right. So database is think of it as a folder. So on your machines. So on your machines why do you create a folder? So that you can save your data in it. Yeah. You can save your files in it. So here also we create the database in order to store the data. In order to store the data now when you have a database why it is uh always better to have a database. So if I ask you again just tell me one thing.
Let's say that you've got a big wardrobe with a lot of clothes in it. Yep. So, don't you think so that if you have got a clothes, if you have got a wardrobe, first of all, uh you're getting a better storage, organized storage. Maybe I'm going to keep all my jackets over here. I'm going to keep all my shirts over here and so on and so forth. So I get to organize my clothes because I'm having a wardrobe, right? Also, I can easily access it. See, if I'm just dumping my clo clothes on the floor, if tomorrow I want a particular dress, yep, it will be very difficult for me to find it, right?
But if I'm using a wardrobe and definitely the wardrobe is organized, then I can easily find the clothes. Yeah. So, it is very easy. it will be very easy for me to access right uh also now uh that is not related to the clothes but yeah in case of database we have one more thing maybe I'll talk about that so talking about the database which is nothing but the storage of data it has organized storage so I just explain you with the help of wardrobe analogy right so you have everything with the help of wardrobe all your clothes are organized Yeah, here also you've got database.
So with the help of database we are getting the organized storage. Then efficient access. So as I told you in case of wardrobe also if your clothes are properly organized it will be very easy for you to access your clothes. So in case of database also it will be very easy for you to access the data because right now see the data can be in uh you know in mega GBs like it can be really huge. It can be really huge. So it is very important that there should be some way to store it so that we can also have efficient access secure scal scalability.
So what do you understand by scalability? Scalability is about increasing the data and data is definitely increasing day by day. Now if you talk about Amazon think about the data that how fast it must be increasing every day there must be a lot of transaction being made. I'm talking about the Amazon website and if I specifically talk about only India Amazon website or only US Amazon website every day you can imagine the kind of transaction that Amazon might be getting and the kind of data that might that Amazon might be producing. So we need a system which is scalable.
Scalable means that it should be able to handle so database is a system which can handle the growing data. Yeah. And it's definitely secure. It provides us the security also. So you may not want all your data to be accessible to everyone. Right? So with the help of database, we can also secure our data. Just like in your wardrobes, you can always lock your wardrobes, right? You can lock and unlock your wardrobes. In the same way, database data can also be locked and unlocked from uh different different users that you have. Okay. There's one thing that I would like to show screen.
You'll get to know that uh how your co-articipants are. For example, I actively work with SQL. So, we have got only two who are actively working on SQL. No experience with SQL. We have almost 53. So, we are going to learn from very very basic and you can see that we are doing that if we are starting from what is data. So, that's one of the very basic thing. Okay. I have got some knowledge but don't use it regularly. So, we have got 16 folks. So we have got a lot of beginners in this batch.
So we'll make sure that we cover everything from scratch. But guys one thing if you're learning the language for the very first time then you also have to make sure that you practice after the class. So only class learning would not be sufficed because see if you don't practice after the class when you come for the next class you're going to forget most of the things what have been taught in the previous class. So again there's one analogy in order to understand what database is. So just like you've got a lot of books. Yeah. So we've got a lot of books.
So the books are stored where? Now this is the picture of what books are stored where? Think of books as the data. And where do we store books? In the library. Yes. Yeah. So this is what library you must have seen that when you go to any of the library usually the books are arranged in a certain manner. For example here you'll have all the science books here you'll have let's say all the maths books all the fctions. So in this way and then there might be some alphab alphabetical arrangement. If you go to any good library you'll see such arrangements.
So why do we have such arrangements? What do you think? Why? What is the reason behind such arrangements? The library stores the book books easy retrieval. Yes, easy accessibility. Yes. Imagine that they are not storing the books in this way and then you'll end up maybe spending your whole day or two in order to find one single book maybe more than that depends on the size of the library. So database also works on the same concept guys. It's just that instead of books we are now storing the data and instead of library we are having the database.
The database stores the data. Library stores book. Now just like how the library is properly just give me a second. Yeah. So just like how the libraries are properly organized so that we can easily access the data and it's not only about access the data I mean I mean to say the books it's all also about let's say there's a new addition yeah I've got a new addition there's a new fiction book so I know that I just have to add it over here so it helps me to modify also properly right I I'll quickly able to modify make the modifications so it's not that I'm very random with it but Yeah, it's mainly for the quick access.
Now we're going to learn about these properties of database. So this is very important interview question also. So we have got asset properties. We call it as asset. So we'll go one by one. So this slide may take little bit of time. So please be patient. So I'll try to make it easy. I'll try to make it interesting. Yeah. All of these properties. But you should definitely know about these properties. These are the heart of the database. So when I say automatomicity, any idea what atomicity could be? So I do not want you guys to read the slides.
I want you guys to answer with whatever comes to your basic minimum terms. Okay fine. So we'll talk about atomicity. So I'll give you an example and we'll understand it with the example and it's very important. So before I talk about atomicity maybe let me tell you the use case of database. So just like database we have got we have got more entities in order to store the data. Now you have to hear me out right? In order to store the data we have got more entities. Database is not the only place where the data is stored.
We have got a lot more other things. So you might have heard about apart from database you might have heard about data warehouse. You might have even heard about data lake. So we are not going to get into that. That's definitely not our area to get into. But what I mean to say is that we have got multiple things in order to store the data. So why what is the use case of database? The question is let's say I've got some data. So why would I choose database rather than data warehouse or data lake. So we are going to look into the use case of database.
Yeah we are not going to look into the use case of data warehouse or data lake. We are going to sorry look into the use case of database. So any idea any use case of database you can think of. See everything is used for storing the data. So why database? So I'll tell you why database. So database or not why I'm just telling you use case of it and then you'll understand why. So we'll go step by step. So if I talk about use case of database. So let's say that I access any of the bank website and when I say website I'm talking about my account.
So I just want to see that what is the balance current balance of my account. what are the transactions that I made in last seven days and so on and so forth. So to save this data now see my current balance then everything related to me my profile then my transactions whatever you see so everything goes into the databases so most of the companies they use databases for such things so databases are used for day-to-day transaction so whenever there is any day-to-day transactions data Yeah, whenever there's a day-to-day transaction data, it goes into the databases.
And the reason is that it provides asset. Yeah, it provides asset guarantees. I'm going to talk about what asset is. But why day-to-day transaction data goes uh why day why do we go with day-to-day transaction? Because because it provides database provides with the asset guarantees. If I give you the other example, if I talk about let's say Amazon, so again day-to-day transaction, right? You're making a payment, you're ordering something, making the payment. So mostly the company might be using the database in order to handle all of these things. So if you go to the Amazon, you see a lot of products.
So let me go to the Amazon and I'll just show that to you. So all of these phones etc. So these are this this is what these are data images the description the price all of these things are data so this might be coming from the database yeah this might be coming from the database so the database might be storing all of these things so for day-to-day transaction we use we use database why for day-to-day transaction because database provides us with the asset properties so we'll talk about atomicity and you'll get to know that Why as it is so important?
So atomicity says it ensures that transactions are executed in all or nothing manner. So what does that mean? So it simply means that let's say let's say this is you and this is your friend. Yeah. Now what you're doing is let's say you have got hear me out. Yeah. You've got 50,000 as your account balance. I'm talking about INR anything anyways. Yeah. And now your friend needs 10,000 rupees. So you say fine I'm going to give you 10,000 rupees. So what you do is you go ahead and you make a transaction. Now this is something that we do in our day-to-day life making the transactions via bank.
So you'll understand that how things works. So here I go ahead and I make 10,000 rupees transaction. So what will happen is the 10,000 will get deducted in your account from your account and it will get credited in your friend's account. So this is the expected behavior when everything goes well. But let's say that you made the transaction. This might have happened a lot of time with you all that you make the transaction the money got debited. Yeah. And hear me out. Yeah. The money got debited from your account, but your friend did not get the credit.
Might have happened, right? So what will happen in your account? You'll see 40,000. But in your friend's account, still it is still reflecting zero. So this is a very bad thing, right? If I talk about banks, this is something that we definitely do not want because if things are happening like this, then we end up calling these people all the customer care and you know breaking our head that we I transferred did not work whatever it is it's definitely not some not something that we would appreciate right so what happened usually in in your day-to-day life you might have seen that if the money is debited from your account and there was some problem while you were making the transaction ction it gots recredited.
You get the message that you have got your money back. So behind the scene what happen is because there's a database that is working. Database says that either all or none. Yeah, it says that either all or none or nothing. So what does that mean? It means that either the whole transaction should get processed successfully. So what I when I say whole transaction should get processed su successfully it means your account is getting debited and your friend's account is getting credited. This is a one full transaction but if there's a problem in between yeah if there's an error in between there's some problem in between then the whole transaction should be rolled back.
So either it should be the full transaction or there should be nothing. And that's why when there's a error while you're making some transfer and if there's some error you you'll get uh you'll get your credit back you'll get your money back automatically and this is because of the database property that is atomicity. So this is a property of the database that either the whole transaction is successful but if there's a problem in between then it will make sure everything is rolled back. So your deducted amount the amount which was deducted is rolled back and it is again credited.
So this is what atomicity is. Now this is so important property. If I talk about banks and if I talk about any other website also Amazon also you make a order. Yeah. Either the order should be made or shouldn't be made. There should be nothing half in between. Right? So atomic city is very very important. Now we're going to talk about consistency. So everybody knows the meaning of Yep. So here it is written but still I write it. So again I'll explain you with the help of an example. So let's say that you've got an account.
Yeah, you've got an account with a bank and you've got 15,000 rupees. Now in your bank and you might have seen that you a lot of banks does have such rules. So let's say that your bank has a rule that you should maintain minimum balance of 10,000. So this is a rule, right? Minimum balance of 10,000. That's a rule. Now what you do is you make a transaction you make a transaction of 10,000 rupees in your friend's account. So how much how much amount is left in your account? How much amount is left? You've got 15,000 and you make a transaction of 10,000.
So how much amount will be left? Minimum balance should be 10,000. So here consistency says rules are not broken. So in very simple words, the rule says that you have to maintain 10,000 rupees in your account. If you try to if you try to transfer 10,000 rupees because you've just got 15,000, it will give you error. it will not allow you to do it. You might have seen on on GP pay, Google pay that there's a limit of 1 lak rupees for every day. So if you try to transfer more than 1 lakh rupees though you might be having even one cr in your account but if you try to transfer more than 1 lak rupees in from your Google pay it gives you error.
It says big no that you're not allowed. So that are what that that is what that is rule. So databases says oh you got some rules I'll make sure that the rules are being followed the rules are not broken. So am I clear? So isolation as the name says it ensures the transaction do not affect each other. So again I'm I'm going to explain it to you with the example. So let's say that you and your sibling or your spouse or your parents you both are using the same account. So it happens right we share the accounts with our loved ones dear ones.
So let's say let's suppose that the account balance is 10,000. Now what is done is let's say you we make a first transaction that is we are taking 5,000 rupees out of the bank. So let's say we are taking 5,000 from the ATM. So the new balance would be what? The new balance will be again 5,000. Now let's say that there's a second transaction and when I say transaction it can mean anything. It's not only about credit and debiting. So the second transaction says that you know it sees it wants to see the data. Yeah.
It want to see like how how much is the account balance. So let's say that you are taking the money out from the ATM and at the same time your parents are checking the balance. Yeah. So they are checking the balance. So they end up they may end up seeing they may end up seeing maybe 5,000 or maybe 10,000. So let's suppose they end up seeing 5,000. Yeah. So your mom is checking and she sees that there is 5,000 rupees. But what happened when you were so you initiated the transaction and ATM uh took its sweet time and then it failed.
Yeah, there was a failure. So what will happen? What will happen? Or maybe you're not taking it from the ATM. You're just doing the online transaction. So you have initiate 5,000 rupees transaction but in between it got failed. So what will happen? It will roll back and you'll again have the 10,000 in your in your account. But your mom is seeing 5,000. So that's a problem you're getting. That's a problem. Actually you don't have 5,000 because your your your transaction feed. So it so everything will roll back and you you actually you have 10,000 rupees only you don't have 5,000 you're getting so you don't have 5,000 you have 10,000 but your mom is seeing 5,000 so that's that's a problem that's a problem so isolation says isolation says that we are going to we are going to do the things in isolation yeah so it means it means that t2 yeah in the transaction to either it will see the old data 10,000 or it will not see anything.
Sometimes the screen takes its sweet time in in order to get refresh or in order to show you the numbers, right? So it will not show you the data half incomplete data. Yeah, half done data. It will not show 5,000 at least. So it either it will show 10 10,000 or it will wait for some time for uh for the transaction to get processed that T1 transaction to get processed successfully and then it will show 5,000 but nothing in between here it was showing in between see you were making the transaction and it is showing 5,000 to your mom but what happened the transaction got failed but your mom sees 5,000 so that's a wrong thing that we are showing right so this is not even before this is not even after this is something in between So isolations make sure that everything happens all the transaction they happens in the isolation.
So they are not affecting each other. So it means that if you're looking into the balance either you're going to see 10,000 or it will take some time and will show you 5,000 once the transaction T1 is successful. So this is what isolation means. Yeah. Means transaction two will not see the uncommitted deduction. As simple as that. So am I clear with isolation? Simple. Everything is something that we get to see in our day-to-day life. Yes Rajar what you're saying is right. Now what is durability? This is a very simple one. So what is the meaning of durable?
Durable simply means that the data is permanent. So it simply means that once the transaction is successful, see 5,000 deducted from your account and credited in your friend's account. Yeah. This yeah this should be durable or the data should be permanent as simple as that. So if there's a power failure even if the system crashes the data will be still saved. So once so it simply means once committed it stays forever and this makes sure that there's no data loss. So I'll just quickly recap. Atomicity says no partial updates. Either should be full or should be none.
Consist consistency says no rules breaking. Isolation says no transaction confusion. and durability says no data loss. So this makes database very very special and that is a why we use it for day-to-day transaction. So there's a word word for day-to-day transaction that is OLTP. So you should definitely know about this thing. It's nothing but online transactional processing. So maybe I'll not write the whole thing. transactional processing. So this simply means day-to-day transaction Amazon your banks. So these are what day-to-day transactions. So all the companies for the OLTP they use databases. So databases are very important.
Okay, whip club I think I've already summarized, right? So what you have to say is for atomicity. So they usually ask like what is atomicity? So you can explain the whole thing that either the transaction should be full transaction or it should be no transaction. So there there should be no partial transaction. Consistency you can give the example that we have got the rule. So we have to make sure that data follows the rule. I give you the example of Google pay also right. So Rajpal let's keep it for the end of the session. Yeah data warehouse we'll cover what is in our curriculum and I'll explain you.
So data warehouse also I'll explain it's a very interesting concept but just keep it for the end of the end of the session. So I'll explain sidesh what you're saying is absolutely I'll quickly explain isolation once again. So isolation simply says think of it maybe I'll give you one maybe one more example. So let's say that you make a transaction you have got 10,000 rupees. Yep. uh you make the transaction of 5,000 at the same time. So I'm explaining you with the same example. At the same time, your spouse looks into the account balance and sees 5,000 rupees.
Now you made the transaction but what happened? Something happened and your transaction got failed and everything got rolled back. So basically you have got 10,000 But your spouse saw 5,000. So your spouse was able to see incomplete data. So either your when you're checking the account, it should be either 10,000 before the transaction or should be 5,000 after the transaction. So it should not be in between. Yeah. When you're making the transaction, understand the transaction is still not completed. Just like let's say you're taking the exam and when you're taking the exam so you're preparing for the exam maybe.
Yep. And you're telling your mom that oh I'm going to top the class. So it's like too soon to say right? So you have to take the exam first and then you can say that okay you have topped the class. But here also it's the same thing that the transaction is ongoing and when the transaction is ongoing this state shouldn't be shown to the user because the transaction is ongoing. So if the transaction fails then if you are showing 5,000 see if you're showing 5,000 then it's a bad data right you're showing the bad data actually the the amount is still 10,000 because the transactions failed but you're showing five 5,000 so that's a bad data.
So either you have to either you should show 10,000 or you should show 5,000 after the successful transaction. Am I clear now? Yes, Raja. Now there are different different type of databases. So we'll I'll quickly give you the brief of the different type of databases. But we are going to focus only on the one type of database which is used in major projects. So we have got different different type of databases. The first one in our list is the relational database. So we are going to learn relational database. Database is what? It's nothing but it's a place where you store your data.
Yeah. Where you store your data. So we have got no SQL graph database centralized distributed in our curriculum we have got relational database SQL works with relational database only. So our focus would be on this but I'll just quickly walk you guys through these also so that you understand these terms. We'll definitely not deep dive that is not required. So let's talk about relational database. Database is what? It's storage of data. So, relational database says that I am going to store the data. Yeah. In the form of the tables. Now, what tables as? Tables as columns.
Yeah. It has columns. Let's say student ID, student name, student number, all of these. Yep. And then it has got data. So this is what this is relational Now we also call it as relational. It means the tables are connected to each other. Yeah, the tables will be connected to each other. So how they are connected to each other? I'll give you one example but we are going to deep dive into this. This is what we are going to learn. So it's very much okay if you do not understand it right away 100%. Yeah, that's very much okay.
If you understand 50% of it, that's also fine. So, for example, let's say that I've got let me let me see if I've got something. Just give me a second. So, instead of writing, I'll better show you. Just give me a second. Yes. Yes. So you can see these are what these are tables with rows with columns and rows. So it's a relational database. So relational database says that this is table let's say this is table one, this is table two and this is table three. So relational database says that there's a relationship between the tables.
Yeah, there's a relationship between the tables. Now, when I say that there's a relationship between the tables, what does that mean? So, if you see for example, so this table is storing the data of the orders, order date, order ID, customer ID, product ID, quantity. So here the customer ID is 1 2 3. So here we are not storing the data of the customer in this table. We are just saying that this transaction is made by the customer with the ID 1 2 3 but we are storing this data of the customer the information of the customer in another table.
So for example 1 2 3 ID is of anul and he is male we can have more information phone number so many so much of it. So this is just to make you understand. So in case of relational databases everything is stored in the form of the table or the data and then we have the relationship between the table. So you can see that this table and this table is related to each other. Yeah, this table and this table is related to each other. So when I say that two things are related to each other.
Let's say that you are related to your uh sibling. So there's something that is common between you. Let's say you're related to each other because of the family. Yeah. In the same way, let's say that you have got multiple friends and you say that okay, I am uh you know somehow I am now that doesn't make much of sense but yeah let's say that I am related to this friend in a way that we all belong to the same college. So that's a key between the relationship uh that's a key between you and your friends to establish the relationship.
So you guys tell me see I've got this table customer table and I've got this orders table. So what do you think what is the key between this table and this table that is actually making the relationship happen. So in order to make the relationship happen there should be some something in common. Yes. Customer ID. Yeah. Tell me about this one and this one now. product ID. I hope this is clear, right? So this is how the relational databases are designed. We are going to deep dive into it. That's what we are going to learn for next eight classes.
Now let's talk about the other databases that we have. Okay, here I've got okay I just totally forgot that I've got a PPD and here I'm showing that how the different tables are related to each other. So there's a key a common key but let it be yeah I have already explained you and we are going anyways going to deep dive into it. Okay a lot of uh speaking from my side again I'm so sorry because I can't help it. Yeah from tomorrow we'll do a lot of hands-on. Now if I give you the examples of the relational database, examples are MySQL.
You're here to learn MySQL. So that's a relational database. In the same way we have got SQL server, Oracle, Postgress. Now if you learn even one single database if you learn MySQL then you can say that you know all of the others and I'll tell you the reason why why because 85 to 90% of all the database they are seen. It's just that there's little bit syntax here and there. So you don't need to learn all the different relational databases. If you learn one, you you will surely be able to work on the others also.
So if I'm let's say I'm taking interview so if I know that the person knows my SQL very well but in my project we are using SQL server I will not hesitate hiring that person because if that person is good as in if that person knows that candidate knows my SQL and he's able to answer all the questions and he understands the length and the breadth of the technology then I'm sure that uh working on SQL server will will be definitely no big deal. So all these databases, relational databases, they're very similar. You don't have to worry about learning different different databases.
That is definitely not required. You learn one properly, you can work on any database for that matter. Fine. Now uh there's one thing about the relational database and why I'm talking about it right now because after this we have got no SQL database. So see relational database is kind of a strict database. So when I say it's a strict database what does that mean? So it simply means that let's say I've got a student. Yeah, I've got you can see over here I'm storing the student details role number name and marks awarded. So let's say I've got a new student.
Yep. Now for this new student I want to store the data but I've got I've got more data for this new new student. So I've got let's say his role number is four name is Nha marks is whatever. Yeah, but I've also got one more data for for him for her. So, let's say I've got city as Pune. So, relational databases say yeah the that I'm so sorry you have something extra I cannot accommodate. So, it's very strict you're getting. So, this table says that you've got extra column. I'm sorry. I can just accommodate three columns.
So I am I cannot provide you this flexibility of storing anything in me. Yeah, I've got three columns. You have to stick to three columns. You cannot give me four columns. So it's very strict. I'll give you one more example of strict. The second strictness it says that now it says that this column is integer. It means that it can take only integer values. Yeah, it can take only integer values. So again I go ahead and give the details but let's say I've got some string value. Yeah I want to give let's say 10. So again it will say no.
It will say what what are you doing? I can just take integer. What the hell are you providing me? You're providing me 10 like the string 10. Sorry I can't do that. So it's very strict. Yeah, it says that see I've created this table with the three columns with a certain data type for all the columns. So for this one we have got the data type as integer. This one let's say as string yeah wcare and so on and so forth. So we have to stick to that. Yeah, we have to stick to that. We'll talk about that apert we'll see to that.
Yep, it's very easy to set these rules. So, you got that that relational database is very very strict. You get that? Am I clear with this point? How do we do that? Once we start writing the code, you'll get to know and it's very easy. It's like one word things. Yeah. You just have to add one keyword and then you're done. done and dusted. Am I clear that the relational database are super strict, very stringent? Fine. Now, let's say there's a requirement. There's a requirement. The requirement is that we want flexibility. Yeah, we want flexibility.
So what I want is let's say that I am um I'm the business owner and I do not want this. Yeah. Because let's say I I I am I am my own school and I say that fine. Yeah. But let's say there's some student with some you know more things. Let's say that he has got some uh he or she has got some certificates or maybe some achievements. So I want to store that data also here. I simply do not want to discard it. Yep. So either you add one more column to your table. Yep.
Or give me something else that is more flexible. I want to store everything. Whatever whoever is coming to my school. Yeah. Whoever is getting registered, whichever student is getting registered in my school, whatever information they are giving me, I want to store it. So I just simply do not want to discard any of the information. So here comes NoSQL databases. So no SQL databases. Now we are not going to get into into the architecture of it. As you can see these are non-tabable databases. Yeah. So it stores the data in a way. Now this also stores the data.
Yeah. This also stores the data but it stores the data in a way that it is super flexible. So do you know what JSON? So relational database stores the data in the form of in the form of uh tables and in case of NoSQL it stores the data in the form of JSON and there are other ways also but I'll show you the JSON one. I'm just uh looking for something that is quite easy to understand. Yeah. So here you here you go. So if you see this is what this is JSON. So for example you've got student.
So we we say student. Yeah. Or let's say employee. Yeah. Employee. So you're storing the first name, last name, display name, middle name, birth name of the employee. Now this is let's say the information of some XX employee. Now let's say that we have got another employee and that another employee has got some other information also. Let's say passport number. So it easily accommodates with that it says fine. So I'm going to have one more node. So this is one node for one data for one employee. So you've got 100 employees. So you'll get 100 nodes.
So it says that I'm very much okay with it. You have got one more data. So I just have to add one more key value pair over here. Yeah. Key. And this is a value. So this is how JSON looks like. So it's very very much accommodating. It says that I'm very much okay with it. Yeah, I'm not strict. Right now I've got five details. Yeah, five columns. If you got 10 columns for the next employee, I can easily accommodate it. So I'm not strict like tables. So that's what NoSQL says. So it stores the data in different different formats.
So it stores the data in key value, column, graph and document format. You don't have to deep dive into it. But yes, so why do we use NoSQL? This you should know. So if you want that flexibility, see tables are very strict. So you want that flexibility that tomorrow if your data comes in some other format, you should be able to store it. Yeah. It should not it should not say no. Your database shouldn't say no. then you can go for NoSQL database. So am I clear with this point? Definitely you don't have to deep dive into it.
XML format. Yes. XML JSON key value pair. Exactly. Okay. The next one is graph database. So I'll take a pause. Why I don't with whatever you see on my slide I want you guys to guess the use case of graph database social media. Fine. So have you seen or you might you on Instagram or Facebook you might have seen that it keeps giving you recommendation of friends of friends mutual connections suggested friends. Have you seen that? So whenever we have got data like this, yeah, where the data is very much related, yeah, it's mutually related.
You can see over here. Yeah. So we use graph database. So friends of friends, so this is again graph database. In the same way product recommendation, so you buy one product, then it starts showing you all the other products. So that can again come under graph database. We have ML also in that it depends but yeah this is what this is graph database. So uh it stores the data in the form of the graph not table. So basically this is you yeah you're browsing Facebook. It will start showing you the mutual connections. This this Yeah.
So this is how it works. You would have never worked on the graph database. Usually uh it is used by the social media companies. Yeah. Social uh media companies. Then uh it is also used by the banks I think for the fraud detection etc. Yeah. But it saves the data as a graph so that they can you can find the connection between the data. Fine. Now we'll talk about centralized So centralized database it can be any database for that matter. It can mean SQL, NoSQL, graph. So centralized database is what you have got one Yeah, you've got one database and everybody's connected to this one So there's only one database.
You have one centralized database and everybody is connected to this centralized database. Let's say that City Bank has got one centralized database. So tell me what could be the problems of having centralized one single big database. What if the database crashes? What if there's a power cut? There's a failure. What will happen? Everything will go down. Now you're not able to access your bank account and so the other users. Yes. So this is a centralized database where you have just got one single big database storing everything and a lot of companies still uses centralized database though it is not recommended now what do you think what should be the solution of centralized database now I'm not expecting the right word for it I'm just expecting that what should be the solution what you you would Don't you think so you have the copies of it multiple copies?
Yeah. So backups. Yes. So if this goes down you have a backup up and running so that you do not uh because of the system crash your website will not go down. As simple as that. So having these backups definitely is pretty expensive because here you are maintaining only one database. Now let's say I have got two backups. So I'll end up maintaining three databases, right? So it's pretty expensive but yes we call it as distributed databases where the data is stored in multiple places and that's is again done by all the big companies and that is the reason why these days you'll not see that your site is going down.
Yeah. All the good big companies websites they are always up and running. So in Pune this happened almost a year back I think it was it happened in June July. So I stay in Hindabari those who are from Pune. So uh there was some issues with the power. Now this area where I'm staying is the IT hub one of the IT hub. So there was some big issue with the power supply of and that was for the whole area and we were without the power for 3 days straight 3 days and it was not only for the households it was for all the IT parks also and uh we have got some data centers when I say data centers um as in uh you can say servers which are storing a lot of data.
So we have got some data center we have got a data center also here in uh this part of Pune in Javari. So everything went down. So definitely the these are very common problems. It can definitely occur. So that's the reason why the companies they always prefer having the distributed So instead of having one centralized database, they're going to have databases at multiple places to avoid uh any downtime. Am I clear? Fine. So let's do one thing. I think we have got a lot of theory and I've been speaking from last one and a half hours.
So it's not uh my thing it's about you guys because if somebody speaks or if you have to listen somebody for more than 20 minutes we tend to uh do a we tend to daydream. So according to some theories I think the attention span of a human being is only 20 minutes not more than that. So we'll do one thing. We'll take a break and after the break we'll continue because we've got the next topic. So I just want to you know cover these topics in continuation or if you're okay maybe I'll take another 15 minutes for these topics not more than that.
Oh wow. Everybody is saying go ahead. I'm so happy. Fine. Let's go back to our library image. I literally have to go back now. Tell me one thing. We've got the data. We've got the books. We have got the library storing the books. Who manages the library? Somebody should also be manage it, right? Who manages the library? Librarian. Okay. So, in we just learn about data. We learn about the database. Don't you think so? We want somebody who can manage the database. We want a tool which can manage which can help us. Anyways, we are going to manage definitely but we want a tool which can help us manage the database.
So let's say if librarian is also managing the library but the librarian might be uh maybe maintaining some book uh some records yeah it might be the librarian might be using something in order to maintain the library. So I remember when I was in college so my because that time it was like long back. So my library teacher uh there was a there was a computer of course in the library in front of uh on on her desk. So she used to use that also she used to maintain one register one copy. Yeah. And she used to write who's taking which book and what's the last date of the submission what's the fine all of these things.
So there's a system that needs uh that we need in order to maintain the things. So here also in order to maintain or not maintain in order to manage the database we have got DBMS here we have got DBMS. So you can see database management system. So database management system is nothing but it allows user to create update retrieve and manage the data in the structure format. So basically see you've got the data you have got the database with a lot of data. Now in order to talk to the database get the data out of it insert the data in it update the data delete the data whatever you want to do with the data for that we need a system.
Yeah we need a system and we call it as DBMS database management system. So it it's a software that helps us manage the databases. So what you can do in this see you can create the database you can read. Yeah you have got the data right. So you can create you can read you can make the updates you can delete it. So you can do all of these things. So these are called CRUD operations. So do not get scared with these jarens technical jargon. These are very simple thing. So when I say CRUD, C stands for what?
Everyone tell me C stands for what? I just talk about the operations. It means create. Yes. So CRUD operation you're going to listen uh to this term a lot. So this is not specific to the databases only like Yep. R stands for what? Read. Yes. Very good. U stands for what? Update. And D stands for delete. So if anybody says CRUD operations, do not get scared of it. What is this CR? It's nothing. You're creating the data. You're just like u you've got a wardrobe. So you are just looking at your wardrobe. How how many clothes you've got.
Maybe you're updating your wardrobe like you're adding something to it. you're removing something from from it and so on and so forth. So here also we do all of these things but we do it with the help of the software called DBFS and guys see um okay maybe I'll talk about that later not right away. Now relational DBMS is what? Tell me what it could be. I just told you what DBM is, what RDB DBMS could be. What RDBMS to manage the relational database? You know that there are so many databases, right? We learned about the relational database.
Now to manage the relational database, what we have? We have got relational DBMS. Simple. So this is a software which help us to manage the database. As simple as that. Now what is SQL? So see understand this thing. Now you've got a software. Now hear me out. Yeah, you've got DBMS software. So you're going to talk to the DBMS and you're going to make the DBM DBMS work for you. Yeah. You say DBMS can you please create a table for me? Of course. So DBMS will create the table for you. But DBMS says that I don't understand plain English.
Yeah. I I I'm not charg I I do don't understand plain English. So DBMS says I can do a lot of things for you but then you have to speak to me in my language the language that I understand. So DBMS in order to talk to DBMS you have to use SQL and that's what we are going to learn. We are going to learn SQL. Why? Because with the help of SQL we can talk to the DBMS and get our work done. Sorry I think there's some issue with the pen. Yeah, get our work done.
That is CRUD. any of the CRUD operations that we want to perform on the database. So you're getting just like let's say there's a librarian. Yeah, librarian is what? Librarian in our analogy is DBMS who manages the database. Yeah. With the U. So then we have got library. So library is what? Library is the database. And inside the library we have got books. So books are what? Books are data. These are data. Now let's say that you want to fetch some book. Yeah. You want to fetch some book. You want some some book. So you go to the librarian and you say that I want so and so book.
Yeah. I want a book of let's say Dan Brown. So and so. So your librarian will go and may fetch it for So you're getting So you're going to talk to the librarian. So you may talk to the librarian in the language that your librarian understands. That makes sense also. Yeah. If your librarian understands only one language that it's English and if you start speaking Spanish in front of that librarian, the librarian would be like what are you saying? I'm like please bother. Yeah. So it will the library will not do your work as simple as that.
So here also in order to talk to the DBMS in order to make DBMS work for us we use SQL as simple as that. Yes. So it understands SQL. So it's a language. It's a query language. So you can see over here that it's a structured query language and it is designed to manage and manipulate the data in relational database manage systems. You use RDBMS, you use SQL and RDBMS. So am I clear what is SQL? So you have got four entities. You've got data. Data is saved in the database. In order to manage the database we have got DBMS.
So in DBMS only we store the data actually. Yep. In the form of the databases. Now in order to make the DBMS work for us we talk to DBMS in SQL language. So Fatima it's very simple. See you're going to use a tool just like if I use Excel. So in order to use Excel, Excel only understands English. So I can just work I can just use I I'm not sure if it has got more languages. I'm not aware about that. But till uh like now I've just used English on Excel. So in case of DBMS also in order to talk to the DBMS you need to use SQL language.
Yeah, that's a language of DBMS. Yes, everything is uh everything is done in DBMS Rajpad. So, we are going to use DBMS. It's a software in order to manage the databases. Fine. So, uh Amin has got a very good question. What is the difference between SQL and MySQL? SQL is a language. Hear me out. Yeah, SQL is a language and MySQL MySQL is the DBMS. So, we have got multiple relational DBMS. We have got multiple relational database management systems in the market. For example, MySQL. Then we have got SQL Server. So, it shares the name with the databases.
Yeah. Shares the name. Same name with the databases Oracle uh sorry for this writing guys and then Postgress I don't know what is happening but yeah so these are this is what this is a DBMS or you can say database also they share the same name in order to talk to the MySQL we use SQL language so SQL is a language and this is a DBMS have I answered your question amin So in order to talk to SQL server also you'll use SQL. In order to talk to Oracle also you're going to use SQL. Postgress also you're going to use SQL.
So SQL is a language and MySQL is the Okay there's some issue I'm not able to write but yeah my SQL posgress SQL server these are what? These are the softwares. Yeah, these are what? These are RDBMS, database management systems. In order to talk to the database management system, we need a language. The language is SQL. So, MySQL is a DBMS and SQL is a language to talk to the It's a coding language. Exactly. So, I think we are done. So, this is a boring topic, but yes, it's in our curriculum. So we are definitely going to cover uh tables and entity relationship model.
So let's keep it for uh let's keep it whatever we have covered so far. A quick recap. We learn about what is data. We learn about what is databases. What what is database? Then we learn about the different type of databases that we have. Also we learn about asset guarantees of database. Then yeah that's all. Yeah that's all mainly then we learn about what is SQL and DBMS. The first and the foremost compon component is entity. So entity is what? Entity is nothing but the real world object. So basically entity you can think of it as a table.
It's a real world object. For example, I gave you the example of student or employee and it is represented with the help of rectangle. Then we have got attributes. So what do you think attributes could be? We just talked about the table. So what attributes could be? So attributes are nothing but the details of the entity. Yes. So all of you are right attributes are the characteristics details yep of an entity. So let me write it. So attribute about they are the property of an entity. So if I give you the example of student, you tell me what could be the attributes.
What could be the attributes for the student table? Student entity ID, name, age, class, marks, etc., etc. Right? So these are nothing but the attributes. Attributes are shown using ovals. Yeah. So whenever you see over it means that it's an attribute. Then we have got relationship. Now you know that tables they can be related to Yeah we'll talk about primary key and foreign key not right now but yes how entities are connected to each other. So I gave you the example of orders table. So you told me that the two tables are connected using customer ID right.
So relationship is how the entities are connected to each other. So if I give you the example let's say that we have got two entities students is one of the entity and course. So course let's say students let's talk about simply learn. So student table has got all the information about you guys and courses table has got all the information about the courses that are provided by simply learn. So if I talk about the relationship between the two. So simply students have enrolled or I would say student has enrolled for which course? Yeah, I'll simply say student enrolls for goals.
Now, I told you that in order to establish the relationship, you need to have the keys. Yeah, you need to have the keys. So, I'll talk about the keys right away. At least I'll give you the little bit idea about it. So, we have a primary key. Now, what is a primary key? So primary key uniquely it uniquely identifies an entity. So if I give you an example over here. So uh before I give you this example, let's talk about a day-to-day life example. So let's say that our government now whether you're sitting in US or India wherever your country is whichever your country is wherever you're sitting so the government is maintaining the database of all the citizens now you I'm Tulika Gupta and there might be hundreds and thousands of tul not hundreds and thousand but at least thousands of tulika Gupta in India right that very much possibility right so my data and the other tulika Gupta data will coincide.
So it has to make sure that we it uniquely identify my my data and it uniquely identify the other tika Gupta's data. So what do you think what government would use? What is my unique identity in India? We have got Aadhaar card. Those who are joining from US, those who are not Indians, maybe passport number, bank card. Yes. So it uniquely identifies an entity. So over here now you guys tell me if I talk about okay in this table we don't have any primary key. Okay in this table can you see any primary key customer ID is a primary key and that makes sense also.
See customer name can be repetitive. We can have a lot of customers with the same name as Ashul and me. So this can be definitely repetitated but how will we un uniquely identify this unshu or how will we differentiate this unshield with the other ano that we have got in our database using the customer ID. Fine. Can you tell me what is the primary key for this table? So we have got the data of the products. So we want a key that will uniquely identify each product. It's product ID. So, am I clear with primary key?
Okay, we'll talk about foreign key now. So, foreign key is basically it connects two entities. Yeah, it connects two entity. So let's say you've got the entity one. It has got some primary key P1. Now we have got entity 2. So in order to connect with entity one, entity 2 is using this primary key. So for this entity, this is not the primary key rather it's a foreign key. Yeah, this is a foreign key. So I'll explain it to you with the help of the example over here. Now again let's talk about this table and this table and we're going to repeat these concepts of primary key and foreign key.
So please make sure that you understand and you remembers the concept. So tell me one thing uh again the same question that I've asked you before the two tables are related with which column? quickly. This table I'm talking about and this table I'm talking about we use over only. These are the attributes. So we use oval only. Yeah. Customer key. Now customer key is what? It's a primary key in this table. Yes, it's a primary key in this table. Now, we are using the primary key of this table in this table. So, for this table, for let's say the name of this table is orders.
For this table, orders ID becomes what? It becomes what? It becomes foreign. Yes, it becomes foreign key. So I repeat I repeat this is what this is a private this is a primary key yeah this is a primary key now in order to connect this entity the customer entity with that of the orders entity the column that I'm using the common column that I'm using is customer ID now for this table customer ID is the primary key but for this table customer ID is what it's a foreign key. It's not a primary key. So foreign key help us to connect the two entities.
Yeah. So this foreign key is a primary key of the one entity and it becomes a foreign key of the other entity. Am I clear? We going to again talk about this. Yes. So see this is what this is a primary key. So when the primary key is referenced in other table in order to establish the relationship between the two entities I repeat when the primary key is referenced into the other table in order to create the relationship between the two tables in order to two tables. Yeah. So it becomes the foreign key on the other table.
So this is what this is a foreign key. We going to revisit this concept when we start our coding. Am I clear now? Sha just remember this thing that whenever you refer primary key in the other table in order to create the relationship between the two entities it becomes a foreign key. Am I clear? So I'll just quickly show you how the diagrams looks like. I think here I'm not I have not created the diagram. Fine. I'll just quickly show you. So it looks like this. You've got the entity. So student entity. This entity may have multiple attributes.
Let's say name. Okay. I'm so sorry. I don't know what is happening. ID. Now I've got another table. Again the name of the table is course. And these two tables are related to each other. So there's a relationship between the two. So this is what enrolls. So this is how we create it. So if somebody gives you any entity diagram, er diagram, you should be able to understand student and courses are nothing but the entities. The ovals that you see are nothing but the attributes of the entities and the diamond that you see are nothing but the relationship of the entities.
Am I clear? Fine. Now in case of attributes also we have got different different type of attributes. No. So, uh there is one I think one exercise for you all. I'll see to that. If you can do it today, that's fine. Otherwise, we'll do it tomorrow. So, I'll ask you to create one year dialogue. So, we'll see. right? So there are different different type of attributes. Now this is little bit boring topic but that's fine. Attributes are nothing but the features of your entity. So we have got the key attribute. Then we have got the derived attribute, multivalued attribute and composite attribute.
So let's cover all of these. So key attributes are nothing but it used to identify one entity from the group of entity. So I just explain you the three attribute. So employee ID, student ID, role number, passport number. These are what these are key attributes. So you can just have a look. Let's look into other attributes that we have got. Now, what are composite attributes? As you can see on my screen, it's very simple. Just give me a second. I think I've got something on the chart. Okay, please go back to the previous slide. Is this the one for product table a okay I'll come to that yes key attributes are primary keys okay for product table a is asking for the product table now tell me for product table I'm talking about the product table the one that I have highlighted what is the primary key the same question product ID and I'm using it in this table.
So in this table a primary key of one entity is used in the other table. So for other table this becomes what? This becomes what? It becomes foreign key. You can also write FK. Yeah, you can just write answers in Y also. No, N. So, I'm very much okay with that. Yeah, you don't have to type in the whole thing. Fine. So, key attributes. I hope I'm clear. Composite is also very simple. So, a lot of time we have got the attributes which are composed of several attributes. So, for example, address. So address is composed of three attributes.
So we have got country, state and zip code and all the values or values of these three makes address. So that's what composite means. Am I clear with composite? Okay. And my laptop is acting up. Just give me a second. Yeah. Anyways, we'll continue. So, what is what are multivalued attributes? Now, there can be some attributes. There can be some attributes which may have multiple values. Yeah. Which may have multiple values. For example, let's say that we have got the attribute order or let's say we have got the attribute. Yep. So we have got the attribute order.
So order let's say that you make a order. Yeah. You make an order. So in ca in case of order in case of order let's say I make an order of a product I'm not able to write. Okay. Okay. There's some issue with the writing thing. Just give me a second. Let me try this. Yep. So let's say we have got the product. Yep. So I buy one product of some quantity, two quantity. I buy the other product of one quantity. So what I mean to say is that these attributes may can have multiple values.
It can have more than one value. So we represent it by double ovals as you can see. So as I told you that you are not going to design the database. That's not your job. So that will be designed by somebody else but you're going to work on the database. You're going to query the database. You're going to generate or play with the data of the database. So you should know if somebody give you this AR diagram, you should be able to know what this ER diagram is representing. And it's a very simple thing. If you see it's just like the walk in the park.
It's so simple. Moving ahead. Yes, all of you are right. So it means that these values see attributes are what? They are like column they are columns, right? So the values of these attributes, the values inside these attributes will be derived from the other attributes. For example, let's say that you have got uh experience. Now we may derive the value of experience uh with the help of let's say I've got the joining date of the employee and today date yeah so experience in our company let's say that it's simply learn employees for simply learn so experience in simply learn how many years in simply learn so see this value can be derived from the other attributes yeah so we do not have the value we we are not going to save the value in this column rather we are going to derive it during the run time.
Yeah. So because see if I save it let's say I save it so today it's 2 years let's let's say yeah so let's say I've saved it 2 years but after 2 months it will be 2 years and 2 months so if I'm saving these value it it may not give me the right values it right now while I'm saving yeah at this point of time maybe it's 2 years for an employee but after a year it will be 3 years so again and again I have to update my database so I I can simply derive it if possible I can simply derive it.
So how I can derive it? Let's say I've got another attributes with the uh start date or the joining date. So Rajpal we usually create the column for the derived attributes. We are going to work on it. We usually create the column for it. But u so it's like you may or may not create the column. You can create this column on the runtime. So anyways, you may or may not create the column. Once we start working on SQL, this will be clear. You'll understand. So am I clear? What are derived attributes everyone? Yes, DH has given a wonderful example price.
So quantity into unit price is total price derive attribute. Perfect. Very good. explanation. Okay, relationship you already Now, uh there are few things that just give me a second. I would like to just give me a second guys. We'll just learn few more terms. I know these are boring but yeah, we'll learn few more term. So, entity sets are what? What? Entity sets are nothing but the relationship. So for example, for we have got employee. Yeah, we have got the employee. We have got three employees. Let's say we have got three employees. Employee one. So let's say employee one is Niha.
Employee two is Joan. Employee 3 is Mark. So entity set will tell us the relationship that Niha is let's say working on so and so project. So let's say this is a project. Yep. So let's say this is a project and this project belongs to so and so department. So with the help of relationship set you at least give the basic idea of how the relationship is. So for example I repeat niha is working on so and so project and this project belongs to so and so department. John is working on so and so project and that belongs to so and so department.
So this is what this is nothing but the relationship set. So you can see that it depicts that E1 works in D2 and E2 works in D3. So E E1 works in D2 and E2 works in D3. So this is something that is not created as a part of the document also to be very honest that you'll see er model for sure that is part created as a part of the document for the database design. So it just give you the brief of some data some dummy data of the entities and how it is connected to the other entities data.
So just give you the glimpse of it. So right now you know about the table. So I'll talk about table only. So tables they they can have relationship with each other. So relationship degree basically tells that the degree of relationship that is between the entities. So basically tells the number of entities that are related to each other. Yeah. The number of entities that are related to each other. So for example if I talk about this one so you can see that I've got only one okay can you tell me how many entities are there how many entities are there they no so those who are saying two it's not two it's one can you see that I yesterday we learned that entities are represented by the rectangle and what is this is a relationship.
So this is a relationship. So basically what it is saying is now hear me out. It's very simple thing. So urary relationship is a relationship where the entity is related to itself. So it's a self relationship where an entity a table is related to itself. So if I give you this example of employee, let's say that we have got the employee table. Now hear me out. It's very simple. So we have got the ID of the employee and then we have got the name of the employee. So let's say 1 2 3 4 and name I'll say A B C D.
Yep, I'm not writing the proper names. And here here let's say I've got one more attribute that is manager. So manager maybe manager ID. So let's say that A's manager is D. So I will say four. B's manager is again D. C's manager is let's say uh let's say B and D there no manager. Yeah. No manager or so over here you can see that the table is related to itself. You're getting so the table is related to itself. So here because if I talk about the manager ID you can see that if I tell you okay let me ask you the question.
So can you tell me what is the name of the manager of A? What is the name of the manager of A? D. Right? So this is what this is self relationship where the table is related to itself. So here because the entity is related to itself we call it as unary relationship. Should I move forward to the next slide? It's a very simple one. If you see now what does binary means? So binary simply means more than uh it means two right it means what it means two. So here you can see that how many entities do we have?
We have got two entities customer and account. So where customer is related to the account. A customer can have accounts right? So we have got the customer table and then we have got the account table. So this is what this is a binary relationship. So it involves how many entities? It involves two entities. I hope I'm clear with this that binary relationship simply involves two It's a very simple one. Let me know if you want reexlanation for any of these. Okay. So how about turnary? So turnary is the relationship where you have got more than two entities.
So basically where we have got three entities. Yeah, three entities involved. And think of entities for now as a table. Think of it that entities is nothing but the synonym of table. So over here you can see that we have got three entities and all the three entities are related to each other. So employees works in a department also employee works with the organization. So and also an organization can have multiple departments. So there is a relationship between the three entities. So am I clear with this one? It's a simple one. Am I clear? Perfect.
Now we'll move to a very interesting topic. the types of relationship. So uh we have got four types of relationship one to one, one to many. So basically see basically one to many and many to one is one of the same thing. It's one of the same thing. So u you would either write one to many or many to one. It's one of the same thing. So actually I say that there are three type of relationship but you'll you'll see that in a lot of blogs they say that there are four type of relationship. So do not get confused.
It's all about how you look at it from left to right or right to left. That's the only thing. Anyways, we're going to talk about it. So allow me a second. So let's talk about one to one relationship. So what is one toone relationship? So if I give you this example. So here we have got the employee table and we have got the employee ID table. So what one:1 relationship says that every single instance of one entity is connected to a single instance of another entity. So here when I say instance what does that mean?
It's not it means nothing but the row or the record. So do not get confused what this instance is. It's nothing but the row or the record. So over here if I talk about this one this example that is being shown on PPT. So let's say I've got the employee table. Yep. I've got an employee table and there are some employees and yes I've got the employee ID also. Let's say ID 1 2 3 4. So here let's say for every employee like here also let's um employee ID is not a very good example rather I'll say bank account.
Yeah. So employees and their respective bank accounts. So here I've got the bank account table. Now when it comes to salary it's the companies you usually ask you to give only one bank account details right? you don't end up giving all the three four that you're holding. So here you've got the bank account details. So again the ID of the employee and some bank yeah let's say city bank or HDFC and so on and so forth. So here the relation is one to one. Why? Because every single instance means every single row. So this is a single row is connected to a single instance of the another entity.
So it means this is connected to a single instance only. It means one instance is related to one instance. I repeat one instance is related to only one instance of the other table. It's not that one instance is related to multiple instance on the other table. one instance is related to only one instance of the other table. So this is what this is one to one. Am I clear? What is one to one? If it is not 100% clear to be very honest once we see what others are like one to many etc. you'll able to understand what does instance means.
So instance means a row sa it means a row one row one record. Yeah. So it's it doesn't mean the column, it means the row. I hope I've answered your question. So guys, am I clear? What is one to one relationship? It's very simple one. But if still you have some confusion, I'm sure your confusion will be clear once we see the other type of relationships that we have. Okay. Now we look into the other one that is one to many. So one to many is where a single instance of one entity is connected to several instance of the other entity.
So what does that mean? What does that mean? Let's say over here you can see that we have got the customer table and then we have got the order table. So this is one table let's say. So I'll just better create my own diagram over here for the better explanation. So let's say I've got the customer table. Now I'm just adding two columns. Um maybe uh yeah let me add three columns. That's fine. Okay. So we have got the ID. Let me add only two. I think two would be suffice. Okay. And then we have got the customer name.
So let's say ID 1 2 3 4. customer name A B C D and here we have got the orders table so order ID and the other things yeah let's say uh the product and etc whatever you can think of so again we have got some orders 10 11 12 13 14 and so on and so forth so here in case of one to many one customer one customer can place multiple orders just like if I talk about Amazon. So you are the one customer, one account, right? And you can place multiple orders, right? So here also one instance, this is what one instance.
This is what one instance is connected to multiple instance of the other table. So one record is connected to the multiple records. It may or may not be connected to the multiple records of the other instant of the other entity. So this is what one to many. This is what one to many. So tell me this is just give me a second I'll just write this is a customer table let's say and this is the orders table. Now tell me which table is on the one side which table is on the one side customer and which table is on the many side order.
Perfect. Now as I told you that one to many and many to one. So this is many to one actually you can see over here but whatever it is yeah one to many or many to one it's one of the same thing it's just that if I put order over here on this side and if I put customer over here so right now it's here it is one and here it is many right so just that if I put order over here then one customer can can order multiple can uh Yeah, order multiple orders. So here we have got order customer.
So order is on the many side and customer is on the one side. So this is one to many or many to one. It's one of the same thing. It's just that you see it like this or this. I hope I'm clear with this point that one to many and many to one is nothing. It's just that right to left or left to right. Okay. So here also I think see they don't have the PPD. Oh no, they have the people. Anyways, so yeah. So anyways, we'll talk about many to many now. So many to many.
Okay, before we maybe hop into many to many, let's make the class interactive. Why don't you give me some example of many to one or one to many? Any any any example. Now guys, one more thing. So when you create the relationship between the two entities, it's not that it's a rule. Like when I say it's a rule, I mean to say that it's not that the employee will be on the many side, the department will be on the one side. This is what we see. So but as per the requirement, you can keep any table on the many side and any table on the one side.
I repeat, as per the business requirement, we can keep any table on side. So it's not that it follows the rule that this has to be on the one side and this has to be on the many side. As simple as that, right? So now I want you guys to give me some examples of many to one or one to many. So I'll give you one example. Okay, I've started getting the examples. Yes, patient appointment date. Very good. Then okay, I'm getting a lot of student subject patient appointment. Okay. Student school. Yes, one school at least in India.
Yeah, one school can have many students. No, that's always goes in India. a student never attends more than one school at least that's how it is for for companies also right if I'm if let's say I'm working with IBM so until I'm moonlighting definitely that is not allowed so one employee sorry uh one company being worked by u one employee working in what I'm saying so one company is uh can have multiple employees Patient table, a medical test table. Very good. B customer, right? Yes. Very good. One nation, many states. Very good. One state, many cities.
One city, many colonies. Perfect. So now we'll move to many to many. One person many bank accounts H. So many to many is when you have got let's say again we have got the employee table and then we have got the project table. So one employee can work on multiple projects. Let's say we have got the projects let's say uh okay I'll just name some of the projects that I've worked on Sunrust etc. So definitely uh there are situations in the company where one employee works in the multiple project right so you may end up working on multiple project also one project is most of the time being worked by multiple employees so here this is one to many so a bc can work on amx but a can also work on sunrust so it's what many to many so I now I want you to contribute some examples on the chat for many to many.
So this is very similar to what we have just covered. But when I say what is cardarity means cardity cardity means how many in a relationship how many. So cardinality tells just give me a second. So basically cardinality tells that how many how many rows of one table can be related to rows of another table. So how many rows of one table can be related to rows of another table. Now you know we just learned about that you know a table we can have tables and suppose there's a one row so one row can be related to only one row of another table or one row can have multiple can be related to multiple rows of another table.
So cardinality is like going one step deeper and telling telling about that if this is a row this is this can have what all values or this this can be connected to what all rows of the another table. Yeah. So a relationship cardality is a number of occurrence of the entity that can be associated with another entity. So basically cardinality will tell suppose you have got a row maybe I'll give you the example in the next on the next slide but it will give you the minimum and the maximum cardinality. So let me go to the next slide and then I'll explain you that would be better.
So if you see over here the cardality is represented over here. So it says zero which is the minimum cardality and n is a maximum cardinality. Here also zero…
Transcript truncated. Watch the full video for the complete content.
More from Simplilearn
Get daily recaps from
Simplilearn
AI-powered summaries delivered to your inbox. Save hours every week while staying fully informed.

![Power BI With AI Full Course 2026 [FREE] | Power BI With AI Tutorial | Power BI Course | Simplilearn thumbnail](https://rewiz.app/images?url=https://i.ytimg.com/vi/rsPa0xeLrYY/maxresdefault.jpg)
![Power BI With AI Full Course 2026 [FREE] | Power BI With AI Tutorial | Power BI Course | Simplilearn thumbnail](https://rewiz.app/images?url=https://i.ytimg.com/vi/RUpsX299R4k/maxresdefault.jpg)
![Tableau Full Course 2026 [FREE] | Tableau Data Visualization Course | Tableau Tutorial | Simplilearn thumbnail](https://rewiz.app/images?url=https://i.ytimg.com/vi/PmW2499tuxU/maxresdefault.jpg)



