1-to-1 Relations Explored in a Knack App
In this video I take you though how to use a 1-to-1 relationship in a Knack database app. Now, 1-to-many relationships (parent-child) are really common, and I suggest learning that concept very well. But a 1-to-1 relation brings with it some other functionality that can be helpful in many use cases.
You see, if it is 1-to-many and you are trying to, lets say, set a Knack rule based on that ... well, since there are "many" possible values to find in the different records, then Knack doesn't know which one to choose. But, if there is only one, then Knack can find that value, and in turn you can set a rule or perform some other function.
This video is a little more advanced, but please check it out.
Interested in my Knack database services? ... Book a call with me here: https://calendly.com/daveparrish/callwithdave
hey folks it's Dave Parish here do another video on that functionality if you like these videos please give it a like on YouTube and subscribe to the channel but here we go today's topic one-to-one relationship explored now this isn't how to fix things up with your girlfriend or boyfriend the granddaddy of all the relationships for all databases is one demanding once you get that concept down you're going to make a lot of progress with how to understand data and how to set up the tables and your whole database there's another one that isn't used that often one to one and why not just use one to many just put one well there's some other functionality that comes up when you're able to use one to one andI'm going to take you through an example of the something I did just this week for a client so I'll be back thanks[Music]hopefully it sounds okay in here I'm in a co-working space in one of these little phone booth rooms let's go for it one-to-one relationships now this isn't the one to many I have another video on that I think but that's really good to learn but jump into my app see if I got it right here's this app to make sure this app um has something to do with medical devices and the testing that they go through before they can be put actually on Market so what this is sort of uh you create a study I'll just go through it study has different products from us it's called a sponsor that'd belike the manufacturer and these different products they want to this isn't collecting clinical data this is similar there's going to be something a device inserted in you or used in a procedure a whole number of things what this does specifically is I'm going to call it a chain of custody whatever physically could happen to this it's sent from the manufacturer to a clinic okay we capture who sent it when they sent it how it was sent tracking numbers all the physical aspects of this thing when it arrives at the facility same thing who received it what condition was in what date all this stuff then its status has changed throughout this whole thing until it's used or potentially disposed of but everything every person every thing that touches this thing is time stamped all kinds of things here's the point of my one-to-one here we have sponsor use so this is XYZ company is making stuff and it's in this study and if a user can either be read only or they can be what's called inventory they can perform actions on this site so picture this you have let's say Joe Blow he works at uh sponsor a company nowhere's the issue I had and this we could make Joe Blow an inventory role or a read-only but if we do that throughsponsor user that means Joe Blow no matter what study he's involved in will always be one or the other and that's not the reality Joe Blow could be on a whole number of studies and some of those studies he could be a read-only and others he could be an inventory person so we needed that was a challenge we needed to capture that and here's how we did that and to where one-to-one content we created a user log know what this does here's a study we're going to keep track of every we have to keep track of all kinds of things it's really detailed but every employee from the sponsor we have to capture okay this is when they we reassigned to be on the study and and when it ended and here's their role so I created a child record to study which is one to many this is a one to many where each study we're going to capture the different people that are on it and what their role is and when they were taking off the study too soI'm going to show you this within here we have this field called roll this is inventory or read only and I made this connected to the user so it's a child each user Joe Blow could have many different instances of him being out of study in each one of those instances but has a rule variable in it but I made what this is is one to one that means we one study can have one instance of JoeBlow on it that seems to reasonable because Joe Blow it's only one person if I made this one to many which will still work I could still accomplish the same sort of tracking when he was put on when it was put off uh but here's whatI'm going to show you it won't do if unless you make it one to oneI'm gonna go over the pages side and here is a study you know I want to make myself smaller sorry guys here's a details of study and here's these are some summer stuff you can't interact with them other than look at it so this is certain read-on but down hereI'm going to do add inventory this is what I sponsors Say Hey I want this device on this site they're going to add another they we're calling the terminology inventory but it's a device now if Joe Blow logs inhere's a rule over here it's at the bottom if the sponsor user log the variable role is read only we're going to hide inventory so it hides this now I'm going to tell you if that wasI'm going to show you this we have all these things you're used to looking through all these things if we made this one too many this section here would not show up it wouldn't even be a deception we can capture to use within a rule and that just doesn't allow it because if it's one to many that means there's many child records that means there could be a number of different values of either inventory or read only so it doesn't know which one to pick so it doesn't even give us the option to do it but if it's one to one it says hey there's only going to be one instance of this Dave on this or there's Joe Blow on this study so we can go look for his his role and determine or make a rule that doesn't soI'm going to give you an example of this and that'll be done let's pop this up here's well this isn't Joe Blow I log in myself but here I am I'm gonna go to this admin sideI'm going to look at a study here let's see what study we're on here x y z say sorry for bouncing around here this isXYZ from the admin cyber they have control of who's what Dave parish is onXYZ my role is read onlyI'm just going to refresh it but it's already there notice since I'm read on I cannot the add inventory button the able to perform an action on this is an hour hitting now let's go back to sponsor management let's make me oh that's under the wrong I like to bean admin we're gonna go here we're gonna make me inventory now so I should be able to formations here's that let's get out of this back to the study okay I admin sorry about these windows here's that I'm working as an ad but nowI'm just updating everyone on here and it made Dave an inventory person so nowI go to this window which is me logged in as a sponsor since I now have been with our inventory of X actions I'm allowed to perform this shows up now this is going to drive down further and further there's all kinds of actions stuff we can be either can be read only or conformed actions so a little way you're able to do that is with the one-to-one relationship instead of a one-to-many that's what I got for you today appreciate it folks thanks