 Jadi hari ini saya adalah seorang seorang seorang seorang yang berbicara. Saya rasa untuk membuat aplikasi reka dalam dua minggu adalah... ...sangat hebat. Kita mempunyai satu buah bulan selama 8 minggu dan dua minggu sangat tidak percaya. Jadi setiap hari, setiap hari, tetap. Saya adalah seorang wanita tank. Macam mana saya boleh lakukan ini? Jadi hari ini saya akan bercakap tentang kecewa yang kita belajar... ...semasa kita belajar sebuah bulan selama 8 minggu... ...untuk aplikasi reka yang digunakan dalam hidup sebenar. Ini menghubungi sedikit tentang apa yang Loxie bercakap tentang sekarang. Macam mana kita berkongsi model yang berbeza bersama. Jadi hari ini, kita akan pergi ke zoo. Jadi... Saya tidak pasti kenapa saya panggil kebinat... ...tapi kemungkinan itu adalah zoo... ...dan kemudian mereka berjaga-jaga dalam kebinat. Saya akan beritahu. Ini tidak akan menjadi sebuah teknikal. Ia akan berlaku seperti sebuah permainan atau sesuatu. Ia akan sangat terang. Saya akan beritahu bahawa orang di sini... ...tidak akan berubah. Jadi ini adalah sebuah kes yang digunakan. Jadi ingat jika ini adalah zoo... ...dan zoo mempunyai banyak kebinat yang digunakan dalam kebinat. Jadi setiap kebinat hanya dapat menggunakan sebuah kebinat. Oleh itu, mereka akan mulakan memikirkan satu sama lain. Kemudian setiap kebinat dapat digunakan dalam beberapa kebinat. Jadi bagaimanapun, dalam kes ini... ...dia akan mempunyai 3 kebinat dalam sebuah kebinat... ...dan kemudian kemudian kebinat yang berbeda di D. Untuk orang yang tidak terlalu terlalu memperkenalkan... ...setiap kebinat menggunakan sebuah kebinat... ...dan setiap kebinat mempunyai banyak kebinat. Dan itu adalah cara menggunakan asositi antara kebinat dan kebinat ini. Jadi dalam kes ini, ini adalah sebuah kebinat dengan kebinat saja. Jadi anda dapat mencari apa yang ada di kebinat... ...dengan mencari kebinat dan kemudian kebinat. Kerana sebuah kebinat yang anda mencari, menghargai kebinat. Dan untuk setiap kebinat, setiap kebinat yang ada di kebinat... ...dia dapat mencari kebinat yang mereka menggunakan... ...dengan mencari kebinat. Dan itu juga sebab anda mencari, ada banyak kebinat di sini. Tapi anda tahu, dalam kebinat, anda mempunyai beberapa kebinat. Jadi di setiap kebinat, anda masih mempunyai kebinat... ...dan anda dapat mempunyai kebinat juga. Tapi anda tahu, tidak ada sebuah kebinat atau sebuah kebinat. Jadi anda menganarakan kebinat ini dulu. Jadi dalam kebinat ini, bagaimana anda menghubungi kebinat... ...dengan sebuah kebinat atau kebinat? Dan anda tahu anda dapat menghubungi kebinat, kadang-kadang seperti ini. Jadi dalam cara kebinat, ia harus dikumpulkan... ...sehingga kadang-kadang kebinat dan kadang-kadang kebinat. Jadi anda menghubungi kebinat anda... ...dengan cara menggunakan kebinat yang mereka nampak. Jadi kebinat yang menggunakan kebinat... ...beri anda dengan cara ini. Jika anda menggunakan... ...jika anda mempunyai kebinat, anda akan menulis tekanan... ...dan anda menggunakan sebuah kebinat ini. Bagaimana anda dapat menggunakan kebinat? Bagaimana anda dapat menggunakan kebinat? Apabila anda menolak kebinat polimofik... ...saya tidak yakin anda menggunakan sebuah kebinat yang betul. Kemudian anda akan menerima bahawa... ...dalam kebinat model... ...dia akan mempunyai sebuah kebinat... ...dengan sebuah kebinat... ...dan sebuah kebinat yang berpengalaman. Sebenarnya anda dapat melihat... ...puan dan sebuah kebinat... ...saya ada dua perkara yang berlainan. Kerana kebinat yang berlainan... ...bukan bila ia bergurau atau berlainan... ...atau kebinat yang berlainan... ...atau bagaimana kebinat yang mereka ada... ...atau bagaimana anda menghubungi kebinat atau apa-apa pun. Jadi, apabila dua model... ...punyai kebinat yang berlainan, anda tidak menulis... ...dan berlainan dengan kebinat. Kemudian dengan pilihan yang berlainan dan pilihan yang berlainan, pilihan yang berlainan adalah tersinggung... ...dengan kebinat A atau P. Apabila anda menulis itu untuk menentu kebinat, ...atau anda akan mencari kebinat dengan pilihan yang berlainan... ...dengan pilihan yang berlainan, seperti 1. Jadi, pilihan yang terlebih... ...kenapa, mempunyai kebinat yang berlainan dengan pilihan P. Jika pilihan yang berlainan adalah 1, You look for in the plant model, the first data in the plant model. So in this case, cabinets can take up, can be linked to two different models. And then the association will look like this, where cabinet belongs to occupiable polymorphic truth and then an animal can have many cabinets, but this time linked to S occupiable and it goes back to the cabinet over here. I think a lot of it is like how you write things and recognize the patterns of that. So this is just part of the syntax. So instead of like before, when each cabinet can only have animals, here you can have either plants or animals. And then when you, just previously, when the cabinet only can have an animal, you call it ad cabinet dot animal, but this time it's associated to occupiable instead. So when you call ad cabinet dot occupiable, the data retrieves either a plant or animal depending on what occupiable type is. And then with that particular animal itself, if you call it ad animal cabinet, then it retrieves what cabinets is this particular animal can be found in. Similarly for plants as well. So the Rails console, if you can test, actually you can just use the Rails console to test how this data is like saved and retrieved and you just find out how to retrieve all this information. You can test your methods over here. So say for instance you have a plant that's a rose, that's a first. So you save it in the variable plant and then you call which plant dot cabinets to find out which cabinet they are found in. And in this case, the array returns nothing, so it's not found anywhere. If you do like plant dot cabinets dot create, it will create a new record of a cabinet called b2. And then it will return instead of nothing, a record here that says, okay, this is the creation of the cabinet itself with the name b2 and the occupable ID1, which is this one here and with the type plant. And then if you go back again to look for plant dot cabinets, it will return you an array with the cabinet that you just assigned it to. And if you create it again, like you do this again, you say like b3, then there will be two records here. And okay, so that last, there's another way of retrieving that information because it's linked both ways, has many and then belongs to. So with the last cabinet just now that you created, cabinet dot last, you do cabinet dot occupable, it will retrieve that plant ID with the name rose there. And here it's not an array, but it's the record of the plant itself because a cabinet can only have one plant. And then if you call the attribute of this occupable, which in this case, you know, refers to a data point of a plant, it will get you rose here and if it's green, this occupable, which is a plant, will return you true because roses is a green plant. Okay, say for instance, you have a cabinet 12 and right now the cabinet is empty. Okay, that's why you see like occupable is new and tight is new as well. And then you assign animal to the last animal and then for the cabinet you just defined in on top, you update with the occupable attribute animal which refers to this snake here. And then you update that particular cabinet itself with the snake and you call it name and the snake will come out here. So, maybe I'll do a little demo of what it looks like on a... Okay, so it's just a very simple view here. Okay, so if the cabinets are arranged like this and you realise okay, the top level should be all plants instead of like a rose and a tiger. So maybe the top row you want it just be like just at plants, right? You can select a plant here instead and then you save the changes. And then you can assign where things will be like this. So, you can see all the plants are on top and then all the animals are below and that's how a cabinet is linked to a different model, either plants or animal here. I mean, this is not a very good example with the animal and plants thing. Okay, so there's a feature that Konrad was supposed to present on and there's single-table inheritance. So, I'll just touch a bit more on what's the difference between single-table inheritance and polymorphic associations. So in single-table inheritance, okay, this is a lot of words but let me just put it in like more layman terms. Usually, why will you use single-table inheritance instead of polymorphic associations is when you're referring to the table itself. It's nothing to do with associations on its own. So, for example, a user, a user can be a customer, a seller, or say admin. So, it's kind of like defining different roles but it shares similar attributes because they're all people. So, say, the user can have an email address, password but say, for example, admin has certain attributes that are specific to them but generally, they share similar attributes and overlapping ones, not necessarily all the attributes. They don't necessarily all the same attributes but they have a lot of overlapping ones and that's when they use case, you use single-table inheritance but for polymorphic associations, it's more sort of how the different models link to each other. So, for example, you have a calendar and you have an appointment and you can link the appointment to a person in your database or a company in your database and a company and person takes up very different attributes, like a company, maybe you're a market capital and then the person maybe you can market capital as well but the attribute will be different. So, in that use case, you wouldn't put companies and models together because the attributes would be totally not overlapping at all. So, that's it. I'm not sure whether it was magic or just confusing. Can I ask the J-Work? What's the false cascade thing? False cascade. Like the database. This one? Yeah. False cascade. Oh, so, when you write your migrations, you define what attributes are there in the table and then you run like RigDB Migrate to translate it to like what? Ya, cool stuff. You can see the different attributes that each model has in a long list and all that. So, this is just what it would look like in the schema which tells you what models you have and what attributes those models have. So, occupiable is actually not a table. Is it a table? No, it's not. I can't find the scientific word for it or like programming word for it but it's kind of like you imagine linking these models through something else. So, it's kind of kind of the medium of vehicle. Ya, to draw the relationship. Ya, so, like the cabinet is linked to the occupiable and then the occupiable is linked to animals and I think it's clear when you see it this way. Ya, because it goes like this way. Ya. So, it's like a table but not a table. It's like an imaginary table. No, no, no. That's not a table at all. It's kind of like a name that you call it by so you can link it to another table that has that name. Ya. It's going to go on YouTube, right? Ya. Ya, any other questions? Cascade. Force Cascade in every app, right? Does it come with it or is it something that you can't think of? I think Force Cascade is nothing special with it. Does it come with it? So, the answer is no long. Ya. I'm quite sure I'm not sure. Ya. It's a database thing. So, I'm not sure about movie. What cascade means is that because you got three tables, right? Or which the data link. If you put cascade, if you delete the data from one table, if you delete the one that's linked, where? If you don't delete, that means you get some data that has stuck because if you delete one side, the other side, the best link gets stuck. So, if you put cascade, you will delete the one that's linked. When you create a table, do you create a migration? Do you use references? Yes, I did. So, it creates a foreign key constraint because it creates a foreign key constraint which links these two tables together. Ya. So, if you delete one without deleting the other or removing the link, it will prevent you from deleting anything. So, if you delete a record, say, from animal, it will prevent you from deleting it if the cabinet has the animal. Ya. So, if you delete the other one, it will prevent you. Ya. Okay. Ya. Ya. I need to... For example, if you delete in cabinet one, the one, maybe let's say, flower and if you delete one, then the flower all goes together. You cannot just delete flower and record the link into three tables which will be left to get that. If you're missing one, it's a record. I can't just say a lot of people the data in one of the tables without deleting get it, you know. Because of this, it can cause the result as well. So, do I have the reference to point to something? Ya. Okay. Wah, that's something new. Thank you. Thank you so much. Ya. Does anyone have any other questions? No? No? Yes? No? The use of the last slide SDIH What's the use? Okay. Okay. Let me see. Ya, so, I was saying okay, the thing is, like in this case, I was saying like with Polymorphic Associations, right? You are trying to associate like one table with two. Ya, but for single table inheritance, right? It only refers to one table. It's nothing got to do with what it relates to. Ya, so for instance, I was saying like a user here, like a user here can be like all of us. And then, like, you know, or like maybe a group of us has like specific role like she's admin. And then the rest of us are all like customers. I mean, I know sometimes, you know, you just use like you define a role, right? And then maybe use an integer. But instead, right, you can if you use, if you call her admin there are like whole group of admins here and then like the rest of us are like customers. It actually allows you to do certain features like you can put admin. Admin, like capital A, admin. So it retrieves like information from that. Am I wrong? Am I wrong? Ya. So for single table inheritance and Polymorphic Associations, so for Polymorphic Associations, as she was saying, you have two fields. You have the idea and the type. So the type actually identifies what table you're looking for, the ID, identify to record ID, which record to retrieve. So use Polymorphic Associations when you actually want to interact with, so let's say for example you're in voice class and you want to interact with what you call available. So available can be a company, can be an individual, can be whatever but you're interacting with it the same way. So you use a Polymorphic Associations I can put in be a company, be a person, or a task into this association and I will interact with it the same way as available. But STI is, let's say you have different models but they more or less share most of the attributes on the scene. So you have additional columns to store attributes that maybe one model has that the other doesn't but since most of them are overlapping, it isn't necessary to split up into multiple models. So you can actually have different models but all referring to the same people. So you save a lot of database space as well depending on how we implement it. So the use cases are probably different in this case. So Connet was supposed to cover STI but she wasn't here. That's why there might be a bit of confusion. Okay. So let's say there is this actually done during runtime as an object so it doesn't necessarily use a database. I mean when you overload the attributes of a particular class you don't actually extend the data to display it to itself. So is that useless? So for STI let's say you have multiple models but for example at the end of the day it's not stored in a database. Yes, it's not. It's not. So your explanation was but this time the overloads are not going to be stored in a database because we are talking about classes or objects. So they will accept it for example. Okay, we're going to stop it now. We can shut it off. Yeah. Do you want to listen to the debate? Yes. You were expecting a chicken like that, right? We want to expose it. I don't think there's a trope in programming. There is. I'm not sure. We can fight about it later. Yeah. Let's talk about it now. No, let's not do that. Okay, so any other questions? Yeah. Let's just start the debate. Yeah, but anyway I think all this is very healthy. We are all beginners and I come from a background that's like non-technical at all. So what are you doing for three months? So thank you. I think it's a lot of peer learning and all that. And you should tell me that I'm wrong because I should know now then later. So thank you. Yeah. Thank you.