Extrodus
|| Blazera.net ||
So basically what I'm doing is creating tables for two new systems that in most simplest terms, replicates the player skills and it will be coded the same way. Attributes and Talents will be defined by number, and just like skills a player will start with all of them at a default number.
So when a player is created, the tables for skills, attributes, and talents will all be filled accordingly with the default information.
The reason for this post is I want to make sure I am defining things properly.
Currently the query is:
What I am here to ask, is UNIQUE KEY even required for this?
My second question is, what do you guys think the best option for setting the default value.
I was thinking an onLogin script that checks if it's the first login, and if so - adds entries to the table for the player. Any suggestions?
So when a player is created, the tables for skills, attributes, and talents will all be filled accordingly with the default information.
The reason for this post is I want to make sure I am defining things properly.
Currently the query is:
Code:
CREATE TABLE IF NOT EXISTS `player_attributes` (
`player_id` int(11) NOT NULL,
`attribute_id` smallint(5) NOT NULL DEFAULT '0',
`points` int(11) NOT NULL DEFAULT '0',
UNIQUE KEY `player_id_2` (`player_id`, `attribute_id`),
FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS `player_talents` (
`player_id` int(11) NOT NULL,
`talent_id` smallint(5) NOT NULL DEFAULT '0',
`points` int(11) NOT NULL DEFAULT '0',
UNIQUE KEY `player_id_2` (`player_id`, `talent_id`),
FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB;
What I am here to ask, is UNIQUE KEY even required for this?
Code:
CREATE TABLE IF NOT EXISTS `player_attributes` (
`player_id` int(11) NOT NULL,
`attribute_id` smallint(5) NOT NULL DEFAULT '0',
`points` int(11) NOT NULL DEFAULT '0',
FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS `player_talents` (
`player_id` int(11) NOT NULL,
`talent_id` smallint(5) NOT NULL DEFAULT '0',
`points` int(11) NOT NULL DEFAULT '0',
FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB;
My second question is, what do you guys think the best option for setting the default value.
I was thinking an onLogin script that checks if it's the first login, and if so - adds entries to the table for the player. Any suggestions?