Posts: 383
Threads: 70
Joined: Feb 2016
Hello there, im currently running a server for like 2-3 weeks and the business system was working okay but now a bug just showed up , when an admin does /mybusinesses it shows him all existing businesses not the one that he owns ( that what cmd is meant to show) , i checked out the databases and saw that at "Owner table" the name was not saving as "NoBody" if there was no owner but as blank space " " , how can i check this shit out to fix it i got no idea
Posts: 383
Threads: 70
Joined: Feb 2016
It was defined as "Null" but i think the problem is coming from SaveBusiness stock.
is there a way i could debug so i can find out whats the matter ?
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
To do it properly the "owner" column should store the id of the player that owns it, not their name. If there isn't an owner then that column should be null.
The importance of proper foreign keys only surfaces the moment a player's name changes or the player's account gets deleted in its entirety. Your artificial relation is suddenly broken and you are left with what are known as "orphaned rows" which are a mess to clean up.
Whereas with proper relations a name change doesn't affect anything because it is only stored in one place and if a user is deleted the database engine automatically does a cleanup, e.g. removing that player as the owner from any businesses.
Posts: 383
Threads: 70
Joined: Feb 2016
So you saying to store the playerid as owner and not their name ?
i also have "SQLID" on my player database and i was thinking to make it for owner instant of players name because that sqlid never changes even if the player has changed the name or did anything