├── LICENSE ├── NOTES.md ├── README.md ├── create_history_tables.sql └── create_tables.sql /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. -------------------------------------------------------------------------------- /NOTES.md: -------------------------------------------------------------------------------- 1 | #DATABASE# 2 | 3 | ##conf## 4 | - Columns 5 | - conf_id 6 | - name 7 | - value 8 | - Constraints 9 | - Primary Key 10 | - conf_id 11 | - Unique Keys 12 | - name 13 | 14 | ##user_type## 15 | - Columns 16 | - user_type_id 17 | - name 18 | - Constraints 19 | - Primary Key 20 | - user_type_id 21 | - Rows 22 | - name:'admin', 23 | - name:'moderator', 24 | - name:'player', 25 | - name:'spectator', 26 | 27 | ##user## 28 | - Columns 29 | - user_id 30 | - user_type_id 31 | - first_name 32 | - last_name 33 | - email 34 | - password 35 | - Constraints 36 | - Primary Key 37 | - user_id 38 | - Foreign Keys 39 | - user_type.user_type_id 40 | 41 | ##character_type## 42 | - Columns 43 | - character_type_id 44 | - name 45 | - Constraints 46 | - Primary Key 47 | - character_type_id 48 | - Rows 49 | - name:'player', 50 | - name:'non-playable', 51 | 52 | ##character## 53 | - Columns 54 | - character_id 55 | - character_type_id 56 | - name 57 | - alive 58 | - level 59 | - xp 60 | - money 61 | - Constraints 62 | - Primary Key 63 | - character_id 64 | - Foreign Keys 65 | - character_type.character_type_id 66 | 67 | ##user_character## 68 | - Columns 69 | - user_character_id 70 | - user_id 71 | - character_id 72 | - Constraints 73 | - Primary Key 74 | - user_character_id 75 | - Unique Keys 76 | - user_id, character_id 77 | - Foreign Keys 78 | - user.user_id 79 | - character.character_id 80 | 81 | ##attribute## 82 | - Columns 83 | - attribute_id 84 | - name 85 | - desc 86 | - Constraints 87 | - Primary Key 88 | - attribute_id 89 | - Rows 90 | - name:'strength', desc:'A measure of how physically strong a character is.', 91 | - name:'constitution', desc:'A measure of how resilient a character is.', 92 | - name:'dexterity', desc:'A measure of how agile a character is.', 93 | - name:'intelligence', desc:'A measure of a character''s problem-solving ability.', 94 | - name:'charisma', desc:'A measure of a character''s social skills, and sometimes their physical appearance.', 95 | - name:'wisdom', desc:'A measure of a character''s common sense and/or spirituality.', 96 | - name:'willpower', desc:'A measure of the character''s mental resistance.', 97 | - name:'perception', desc:'A measure of a character''s openness to their surroundings.', 98 | - name:'luck', desc:'A measure of a character having chance to favor him or her.', 99 | - name:'damage', desc: 'A measure to inflict damage', 100 | 101 | ##character_attribute## 102 | - Columns 103 | - character_attribute_id 104 | - character_id 105 | - attribute_id 106 | - value 107 | - Constraints 108 | - Primary Key 109 | - character_attribute_id 110 | - Unique Keys 111 | - character_id, attribute_id 112 | - Foreign Keys 113 | - character.character_id 114 | - attribute.attribute_id 115 | 116 | ##place## 117 | - Columns 118 | - place_id 119 | - name 120 | - Constraints 121 | - Primary Key 122 | - place_id 123 | 124 | ##location## 125 | - Columns 126 | - location_id 127 | - x 128 | - y 129 | - place_id 130 | - Constraints 131 | - Primary Key 132 | - location_id 133 | - Unique Keys 134 | - x, y 135 | - Foreign Keys 136 | - place.place_id 137 | 138 | ##character_location## 139 | - Columns 140 | - character_location_id 141 | - character_id 142 | - location_id 143 | - Constraints 144 | - Primary Key 145 | - character_location_id 146 | - Unique Keys 147 | - character_id 148 | - Foreign Keys 149 | - character.character_id 150 | - location.location_id 151 | 152 | ##item_type## 153 | - Columns 154 | - item_type_id 155 | - name 156 | - desc 157 | - Constraints 158 | - Primary Key 159 | - item_type_id 160 | 161 | ##item## 162 | - Columns 163 | - item_id 164 | - item_type_id 165 | - name 166 | - required_level 167 | - durability 168 | - Constraints 169 | - Primary Key 170 | - item_id 171 | - Foreign Keys 172 | - item_type.item_type_id 173 | 174 | ##item_attribute## 175 | - Columns 176 | - item_attribute_id 177 | - item_id 178 | - attribute_id 179 | - value 180 | - Constraints 181 | - Primary Key 182 | - item_attribute_id 183 | - Unique Keys 184 | - item_id, attribute_id 185 | - Foreign Keys 186 | - item.item_id 187 | - attribute.attribute_id 188 | 189 | ##item_location## 190 | - Columns 191 | - item_location_id 192 | - item_id 193 | - location_id 194 | - Constraints 195 | - Primary Key 196 | - item_location_id 197 | - Unique Keys 198 | - item_id 199 | - Foreign Keys 200 | - item.item_id 201 | - location.location_id 202 | 203 | ##character_item## 204 | - Columns 205 | - character_item_id 206 | - character_id 207 | - item_id 208 | - Constraints 209 | - Primary Key 210 | - character_item_id 211 | - Unique Keys 212 | - character_id, item_id 213 | - Foreign Keys 214 | - character.character_id 215 | - item.item_id 216 | 217 | ##equipment_slot## 218 | - Columns 219 | - equipment_slot_id 220 | - name 221 | - Constraints 222 | - Primary Key 223 | - equipment_slot_id 224 | - Unique Keys 225 | - name 226 | - Rows 227 | - name:'head', 228 | - name:'shoulder', 229 | - name:'chest', 230 | - name:'back', 231 | - name:'wrist', 232 | - name:'hands', 233 | - name:'waist', 234 | - name:'leg', 235 | - name:'feet', 236 | - name:'neck', 237 | - name:'ears', 238 | - name:'ring', 239 | - name:'main_hand', 240 | - name:'off_hand', 241 | 242 | ##character_equipment## 243 | - Columns 244 | - character_equipment_id 245 | - equipment_slot_id 246 | - character_id 247 | - item_id 248 | - Constraints 249 | - Primary Key 250 | - equipment_slot_id 251 | - Unique Keys 252 | - equipment_slot_id, character_id 253 | - Foreign Keys 254 | - equipment_slot.equipment_slot_id 255 | - character.character_id 256 | - item.item_id 257 | 258 | ##class## 259 | - Columns 260 | - class_id 261 | - name 262 | - Constraints 263 | - Primary Key 264 | - class_id 265 | - Unique Keys 266 | - name 267 | 268 | ##character_class## 269 | - Columns 270 | - character_class_id 271 | - character_id 272 | - class_id 273 | - Constraints 274 | - Primary Key 275 | - character_class_id 276 | - Unique Keys 277 | - character_id 278 | - Foreign Keys 279 | - character.character_id 280 | - class.class_id 281 | 282 | ##ability_type## 283 | - Columns 284 | - ability_type_id 285 | - name 286 | - desc 287 | - Constraints 288 | - Primary Key 289 | - ability_type_id 290 | 291 | ##ability## 292 | - Columns 293 | - ability_id 294 | - name 295 | - ability_type_id 296 | - required_level 297 | - Constraints 298 | - Primary Key 299 | - ability_id 300 | - Foreign Keys 301 | - ability.ability_type_id 302 | 303 | ##class_ability## 304 | - Columns 305 | - class_ability_id 306 | - class_id 307 | - ability_id 308 | - Constraints 309 | - Primary Key 310 | - class_ability_id 311 | - Unique Keys 312 | - class_id, ability_id 313 | - Foreign Keys 314 | - class.class_id 315 | - ability.ability_id 316 | 317 | ##effect_type## 318 | - Columns 319 | - effect_type_id 320 | - name 321 | - desc 322 | - Constraints 323 | - Primary Key 324 | - effect_type_id 325 | - Rows 326 | - name:'buff', desc:'A temporary benefit to a character’s attributes', 327 | - name:'debuff', desc:'A temporary hindrance to a character’s attributes', 328 | 329 | ##status_effect## 330 | - Columns 331 | - status_effect_id 332 | - name 333 | - effect_type_id 334 | - duration 335 | - desc 336 | - Constraints 337 | - Primary Key 338 | - status_effect_id 339 | - Foreign Keys 340 | - effect_type.effect_type_id 341 | 342 | ##character_status_effect## 343 | - Columns 344 | - character_status_effect_id 345 | - character_id 346 | - status_effect_id 347 | - date 348 | - Constraints 349 | - Primary Key 350 | - character_status_effect_id 351 | - Foreign Keys 352 | - status_effect.status_effect_id 353 | - character.character_id 354 | 355 | ##loot## 356 | - Columns 357 | - loot_id 358 | - xp 359 | - money 360 | - Constraints 361 | - Primary Key 362 | - loot_id 363 | 364 | ##character_loot## 365 | - Columns 366 | - character_loot_id 367 | - loot_id 368 | - character_id 369 | - Constraints 370 | - Primary Key 371 | - character_loot_id 372 | - Foreign Keys 373 | - loot.loot_id 374 | - character.character_id 375 | 376 | ##item_loot## 377 | - Columns 378 | - item_loot_id 379 | - loot_id 380 | - item_id 381 | - drop_chance 382 | - Constraints 383 | - Primary Key 384 | - item_loot_id 385 | - Foreign Keys 386 | - loot.loot_id 387 | - item.item_id 388 | 389 | ##entity_type## 390 | - Columns 391 | - entity_type_id 392 | - name 393 | - Constraints 394 | - Primary Key 395 | - entity_type_id 396 | 397 | ##entity## 398 | - Columns 399 | - entity_id 400 | - entity_type_id 401 | - name 402 | - level 403 | - Constraints 404 | - Primary Key 405 | - entity_id 406 | - Foreign Keys 407 | - entity_type.entity_type_id 408 | 409 | ##entity_attribute## 410 | - Columns 411 | - entity_attribute_id 412 | - entity_id 413 | - attribute_id 414 | - value 415 | - Constraints 416 | - Primary Key 417 | - entity_attribute_id 418 | - Unique Keys 419 | - entity_id, attribute_id 420 | - Foreign Keys 421 | - entity.entity_id 422 | - attribute.attribute_id 423 | 424 | ##entity_location## 425 | - Columns 426 | - entity_location_id 427 | - entity_id 428 | - location_id 429 | - Constraints 430 | - Primary Key 431 | - entity_location_id 432 | - Unique Keys 433 | - entity_id 434 | - Foreign Keys 435 | - entity.entity_id 436 | - location.location_id 437 | 438 | ##entity_class## 439 | - Columns 440 | - entity_class_id 441 | - entity_id 442 | - class_id 443 | - Constraints 444 | - Primary Key 445 | - entity_class_id 446 | - Unique Keys 447 | - entity_id 448 | - Foreign Keys 449 | - entity.entity_id 450 | - class.class_id 451 | 452 | ##entity_status_effect## 453 | - Columns 454 | - entity_status_effect_id 455 | - entity_id 456 | - status_effect_id 457 | - date 458 | - Constraints 459 | - Primary Key 460 | - entity_status_effect_id 461 | - Foreign Keys 462 | - status_effect.status_effect_id 463 | - entity.entity_id 464 | 465 | ##entity_loot## 466 | - Columns 467 | - entity_loot_id 468 | - loot_id 469 | - entity_id 470 | - Constraints 471 | - Primary Key 472 | - entity_loot_id 473 | - Foreign Keys 474 | - loot.loot_id 475 | - entity.entity_id 476 | 477 | ##faction## 478 | - Columns 479 | - faction_id 480 | - name 481 | - Constraints 482 | - Primary Key 483 | - faction_id 484 | 485 | ##character_faction## 486 | - Columns 487 | - character_faction_id 488 | - character_id 489 | - faction_id 490 | - Constraints 491 | - Primary Key 492 | - character_faction_id 493 | - Foreign Keys 494 | - character.character_id 495 | - faction.faction_id 496 | 497 | ##entity_faction## 498 | - Columns 499 | - entity_faction_id 500 | - entity_id 501 | - faction_id 502 | - Constraints 503 | - Primary Key 504 | - entity_faction_id 505 | - Foreign Keys 506 | - entity.entity_id 507 | - faction.faction_id 508 | 509 | ##rank## 510 | - Columns 511 | - guild_id 512 | - name 513 | - Constraints 514 | - Primary Key 515 | - guild_id 516 | 517 | ##guild## 518 | - Columns 519 | - guild_id 520 | - name 521 | - Constraints 522 | - Primary Key 523 | - guild_id 524 | 525 | ##guild_rank## 526 | - Columns 527 | - guild_rank_id 528 | - guild_id 529 | - rank_id 530 | - Constraints 531 | - Primary Key 532 | - guild_rank_id 533 | - Unique Keys 534 | - guild_id, rank_id 535 | - Foreign Keys 536 | - guild.guild_id 537 | - rank.rank_id 538 | 539 | ##character_guild## 540 | - Columns 541 | - character_guild_id 542 | - character_id 543 | - guild_id 544 | - guild_leader 545 | - Constraints 546 | - Primary Key 547 | - character_guild_id 548 | - Unique Keys 549 | - guild_id, guild_leader 550 | - Foreign Keys 551 | - character.character_id 552 | - guild.guild_id 553 | 554 | ##character_guild_rank## 555 | - Columns 556 | - character_guild_rank_id 557 | - character_id 558 | - guild_rank_id 559 | - Constraints 560 | - Primary Key 561 | - character_guild_rank_id 562 | - Unique Keys 563 | - character_id, guild_rank_id 564 | - Foreign Keys 565 | - character.character_id 566 | - guild_rank.guild_rank_id 567 | 568 | ##party## 569 | - Columns 570 | - party_id 571 | - Constraints 572 | - Primary Key 573 | - party_id 574 | 575 | ##character_party## 576 | - Columns 577 | - character_party_id 578 | - character_id 579 | - party_id 580 | - party_leader 581 | - Constraints 582 | - Primary Key 583 | - character_party_id 584 | - Unique Keys 585 | - character_id 586 | - party_id, party_leader 587 | - Foreign Keys 588 | - character.character_id 589 | - party.party_id 590 | 591 | ##title## 592 | - Columns 593 | - title_id 594 | - name 595 | - Constraints 596 | - Primary Key 597 | - title_id 598 | 599 | ##character_title## 600 | - Columns 601 | - character_title_id 602 | - character_id 603 | - title_id 604 | - Constraints 605 | - Primary Key 606 | - character_title_id 607 | - Foreign Keys 608 | - character.character_id 609 | - title.title_id 610 | 611 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MySQL-RPG-Schema 2 | 3 | A database schema for role-playing games 4 | 5 | # Description 6 | 7 | This repo contains a database template that could be used when designing an RPG. 8 | 9 | There is a possibility that this schema may not fit your exact needs, but it could be used as a jump off point to get you going. Hopefully, there is enough here where you can use most of it and modify the bits and peices you need. 10 | 11 | The schema here is intended for a MySQL database. 12 | 13 | You may want to take into consideration using either MyISAM or Innodb. Each have their advantages and disadvantages. I've considered making these Innodb, but decided to leave that out. If you have a preference on using a particular database engine, then you may need to modify the schema. 14 | 15 | 16 | # Synopsis 17 | 18 | The "create_tables.sql" file will have the database schema to the create tables. 19 | 20 | The "create_history_tables.sql" file creates a history table for each table. Having history tables is intended to be optional hence being in a seperate file. 21 | 22 | 23 | # Database Tables 24 | 25 | Below is an overview on individual database tables. 26 | 27 | 28 | ## conf 29 | 30 | Various configuration settings for your game *could* be held here. 31 | 32 | Columns: 33 | - conf_id 34 | - name 35 | - value 36 | 37 | 38 | ## user_type 39 | 40 | Different user types that would be associated with a "user" (not to be confused with "characters"). 41 | 42 | Columns: 43 | - user_type_id 44 | - name 45 | 46 | Rows: 47 | - name:'admin', 48 | - name:'moderator', 49 | - name:'player', 50 | - name:'spectator', 51 | 52 | 53 | ## user 54 | 55 | This table holds the real world player information. Entries inside here are known as "users", which differ from "characters" 56 | 57 | Columns: 58 | - user_id 59 | - user_type_id 60 | - first_name 61 | - last_name 62 | - email 63 | - password 64 | 65 | 66 | ## character_type 67 | 68 | Different character types that are associated with a "character". 69 | 70 | Columns: 71 | - character_type_id 72 | - name 73 | 74 | Rows: 75 | - name:'player', 76 | - name:'non-playable', 77 | 78 | 79 | ## character 80 | 81 | Records inside here would be characters in your game. This table includes playable and non-playable characters. 82 | 83 | Columns: 84 | - character_id 85 | - character_type_id 86 | - name 87 | - alive 88 | - level 89 | - xp 90 | - money 91 | 92 | 93 | ## user_character 94 | 95 | This table links "users" to "characters". It is recomended that the character a user will associate with should have a character_type (SEE character_type) classifing the character as "player". 96 | 97 | Columns: 98 | - user_character_id 99 | - user_id 100 | - character_id 101 | 102 | 103 | ## attribute 104 | 105 | A basic list of attributes. 106 | 107 | See this [wiki article](http://en.wikipedia.org/wiki/Attribute_(role-playing_games)) in regards to rpg attributes. 108 | 109 | Columns: 110 | - attribute_id 111 | - name 112 | - desc 113 | 114 | Initial rows inserted: 115 | - name:'strength', desc:'A measure of how physically strong a character is.', 116 | - name:'constitution', desc:'A measure of how resilient a character is.', 117 | - name:'dexterity', desc:'A measure of how agile a character is.', 118 | - name:'intelligence', desc:'A measure of a character''s problem-solving ability.', 119 | - name:'charisma', desc:'A measure of a character''s social skills, and sometimes their physical appearance.', 120 | - name:'wisdom', desc:'A measure of a character''s common sense and/or spirituality.', 121 | - name:'willpower', desc:'A measure of the character''s mental resistance.', 122 | - name:'perception', desc:'A measure of a character''s openness to their surroundings.', 123 | - name:'luck', desc:'A measure of a character having chance to favor him or her.', 124 | - name: 'damage', desc: 'A measure to inflict damage', 125 | 126 | 127 | ## character_attribute 128 | 129 | This table associates attributes to characters. 130 | 131 | Columns: 132 | - character_attribute_id 133 | - character_id 134 | - attribute_id 135 | - value 136 | 137 | 138 | ## place 139 | 140 | Used by "location", This table holds a list of place names. 141 | 142 | Columns: 143 | - place_id 144 | - name 145 | 146 | 147 | ## location 148 | 149 | A list of x and y coordinates. Each record will be associated with a "place" (SEE "place" TABLE). You can have multiple location records that are of the same place. 150 | 151 | Columns: 152 | - location_id 153 | - x 154 | - y 155 | - place_id 156 | 157 | 158 | ## character_location 159 | 160 | A list reporting where characters are at. 161 | 162 | Columns: 163 | - character_location_id 164 | - character_id 165 | - location_id 166 | 167 | 168 | ## item_type 169 | 170 | Different item types held here. 171 | 172 | Columns: 173 | - item_type_id 174 | - name 175 | - desc 176 | 177 | 178 | ## item 179 | 180 | An object that characters can use in some way. 181 | 182 | Columns: 183 | - item_id 184 | - item_type_id 185 | - name 186 | 187 | 188 | ## item_attribute 189 | 190 | This table associates items with attributes. These attributes are intended to be added to character attributes. 191 | 192 | Columns: 193 | - item_attribute_id 194 | - item_id 195 | - attribute_id 196 | - value 197 | 198 | 199 | ## item_location 200 | 201 | A list of item locations. It is intended that if a character has an item on them, then the item will not be in this table. 202 | 203 | Columns: 204 | - item_location_id 205 | - item_id 206 | - location_id 207 | 208 | 209 | ## character_item 210 | 211 | The "character inventory", what the character has on them or perhaps in a backpack of sorts. If an item is equiped, then it is not intended to be in here. However, it is possible to have equipped items in here also. 212 | 213 | Columns: 214 | - character_item_id 215 | - character_id 216 | - item_id 217 | 218 | 219 | ## equipment_slot 220 | 221 | A list of possible slots where items can be equiped to. 222 | 223 | Columns: 224 | - equipment_slot_id 225 | - name 226 | 227 | Initial rows inserted: 228 | - name:'head', 229 | - name:'shoulder', 230 | - name:'chest', 231 | - name:'back', 232 | - name:'wrist', 233 | - name:'hands', 234 | - name:'waist', 235 | - name:'leg', 236 | - name:'feet', 237 | - name:'neck', 238 | - name:'ears', 239 | - name:'ring', 240 | - name:'main_hand', 241 | - name:'off_hand', 242 | 243 | 244 | ## character_equipment 245 | 246 | A list of items that are equiped to characters. 247 | 248 | Columns: 249 | - character_equipment_id 250 | - equipment_slot_id 251 | - character_id 252 | - item_id 253 | 254 | 255 | ## class 256 | 257 | A list of classes that characters can be. 258 | 259 | See this [wiki article](http://en.wikipedia.org/wiki/Character_class) in regards to what rpg classes are and the different types. 260 | 261 | Columns: 262 | - class_id 263 | - name 264 | 265 | 266 | ## character_class 267 | 268 | This table associates characters to a class (SEE "class" TABLE) 269 | 270 | Columns: 271 | - character_class_id 272 | - character_id 273 | - class_id 274 | 275 | 276 | ## ability_type 277 | 278 | Different ability types held here (SEE "ability" TABLE). 279 | 280 | Columns: 281 | - ability_type_id 282 | - name 283 | - desc 284 | 285 | 286 | ## ability 287 | 288 | An ability is like a special action, spell, or possible talent that characters can perform in combat. 289 | 290 | Columns: 291 | - ability_id 292 | - name 293 | - ability_type_id 294 | 295 | 296 | ## class_ability 297 | 298 | This table associates what class can do an ability. 299 | 300 | Columns: 301 | - class_ability_id 302 | - class_id 303 | - ability_id 304 | 305 | 306 | ## effect_type 307 | 308 | Different effect types held here. 309 | 310 | Columns: 311 | - effect_type_id 312 | - name 313 | - desc 314 | 315 | Rows: 316 | - name:'buff', desc:'A temporary benefit to a character’s attributes', 317 | - name:'debuff', desc:'A temporary hindrance to a character’s attributes', 318 | 319 | 320 | ## status_effect 321 | 322 | A "status effect" is usually some temporary advantage or hindrance given to a character by some mean, perhaps from an ability, an item, or being at some place. 323 | 324 | See this [wiki article](http://en.wikipedia.org/wiki/Status_effect) in regards to what rpg status effects are and examples. 325 | 326 | Columns: 327 | - status_effect_id 328 | - name 329 | - effect_type_id 330 | - duration 331 | - desc 332 | 333 | 334 | ## character_status_effect 335 | 336 | This table associates current status effects are on character. 337 | 338 | Columns: 339 | - character_status_effect_id 340 | - character_id 341 | - status_effect_id 342 | - date 343 | 344 | 345 | ## loot 346 | 347 | This table lists the possible loot that can be gained. 348 | 349 | Columns: 350 | - loot_id 351 | - xp 352 | - money 353 | 354 | 355 | ## character_loot 356 | 357 | This table associates loot awarded when defeating a specific character. 358 | 359 | Columns: 360 | - character_loot_id 361 | - loot_id 362 | - character_id 363 | 364 | 365 | ## item_loot 366 | 367 | This table associates items awarded when receiving a particular loot. 368 | 369 | The "drop_chance" column sets the chance of receiving this item. This column is intended to be a decimal number between 0 to 1 as a way to represent a percentage. 370 | 371 | Columns: 372 | - item_loot_id 373 | - loot_id 374 | - item_id 375 | - drop_chance 376 | 377 | 378 | ## entity_type 379 | 380 | A list of basic types associated with entities. 381 | 382 | Columns: 383 | - entity_type_id 384 | - name 385 | 386 | 387 | ## entity 388 | 389 | An "entity" is an alternative to the "non-playable" character type. This table is intended to have various non playable characters in your game. These could be friendly or hostile to players. They can be ugly monsters or beautiful human. It is really up to you if you want to use this table or how you want to use it. 390 | 391 | Columns: 392 | - entity_id 393 | - entity_type_id 394 | - name 395 | - level 396 | 397 | 398 | ## entity_attribute 399 | 400 | Associates an attribute to an entity. 401 | 402 | Columns: 403 | - entity_attribute_id 404 | - entity_id 405 | - attribute_id 406 | - value 407 | 408 | 409 | ## entity_location 410 | 411 | Gives an entity a location. 412 | 413 | Columns: 414 | - entity_location_id 415 | - entity_id 416 | - location_id 417 | 418 | 419 | ## entity_class 420 | 421 | Assign an entity to a class. 422 | 423 | Columns: 424 | - entity_class_id 425 | - entity_id 426 | - class_id 427 | 428 | 429 | ## entity_status_effect 430 | 431 | Associates a current status effect with an entity (SEE "status_effect" TABLE) 432 | 433 | Columns: 434 | - entity_status_effect_id 435 | - entity_id 436 | - status_effect_id 437 | - date 438 | 439 | 440 | ## entity_loot 441 | 442 | Associates loot awarded when defeating a specific entity. 443 | 444 | Columns: 445 | - entity_loot_id 446 | - loot_id 447 | - entity_id 448 | 449 | 450 | ## faction 451 | 452 | A global and permenant group of characters ("playable" or "non-playable") and entities that share some idea. That idea could be political, religious, cultural, spiritual, or something different entirely. 453 | 454 | Columns: 455 | - faction_id 456 | - name 457 | 458 | 459 | ## character_faction 460 | 461 | Associates a character to a faction. 462 | 463 | Columns: 464 | - character_faction_id 465 | - character_id 466 | - faction_id 467 | 468 | 469 | ## entity_faction 470 | 471 | Associates an entity to a faction. 472 | 473 | Columns: 474 | - entity_faction_id 475 | - entity_id 476 | - faction_id 477 | 478 | 479 | ## rank 480 | 481 | A list of generic rank names. 482 | 483 | Columns: 484 | - guild_id 485 | - name 486 | 487 | 488 | ## guild 489 | 490 | A global and permenant group of playable characters working together. 491 | 492 | Columns: 493 | - guild_id 494 | - name 495 | 496 | 497 | ## guild_rank 498 | 499 | A list of ranks associated to a particular guild. 500 | 501 | Columns: 502 | - guild_rank_id 503 | - guild_id 504 | - rank_id 505 | 506 | 507 | ## character_guild 508 | 509 | Associates a character to a guild. 510 | 511 | Columns: 512 | - character_guild_id 513 | - character_id 514 | - guild_id 515 | - guild_leader 516 | 517 | 518 | ## character_guild_rank 519 | 520 | Associates a character to a guild_rank. 521 | 522 | Columns: 523 | - character_guild_rank_id 524 | - character_id 525 | - guild_rank_id 526 | 527 | 528 | ## party 529 | 530 | A small and likely temporary group of players trying to accomplish an objective. 531 | 532 | Columns: 533 | - party_id 534 | 535 | 536 | ## character_party 537 | 538 | Associates a character to a party. 539 | 540 | Columns: 541 | - character_party_id 542 | - character_id 543 | - party_id 544 | - party_leader 545 | 546 | 547 | ## title 548 | 549 | A list of titles. 550 | 551 | Columns 552 | - title_id 553 | - name 554 | 555 | 556 | ## character_title 557 | 558 | Associates a character to a title. 559 | 560 | Columns 561 | - character_title_id 562 | - character_id 563 | - title_id 564 | 565 | -------------------------------------------------------------------------------- /create_history_tables.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `h_conf` ( 2 | h_conf_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 3 | h_action ENUM('create', 'update', 'delete'), 4 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 5 | `conf_id` int(11) UNSIGNED NOT NULL, 6 | `name` varchar(255) NOT NULL, 7 | `value` varchar(255), 8 | PRIMARY KEY (`h_conf_id`) 9 | ); 10 | 11 | CREATE TABLE `h_user_type` ( 12 | h_user_type_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 13 | h_action ENUM('create', 'update', 'delete'), 14 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 15 | `user_type_id` int(11) UNSIGNED NOT NULL, 16 | `name` varchar(255) NOT NULL, 17 | PRIMARY KEY (`h_user_type_id`) 18 | ); 19 | 20 | CREATE TABLE `h_user` ( 21 | h_user_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 22 | h_action ENUM('create', 'update', 'delete'), 23 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 24 | `user_id` int(11) UNSIGNED NOT NULL, 25 | `user_type_id` int(11) UNSIGNED NOT NULL, 26 | `first_name` varchar(255) NOT NULL, 27 | `last_name` varchar(255) NOT NULL, 28 | `email` varchar(255) NOT NULL, 29 | `password` varchar(255) NOT NULL, 30 | PRIMARY KEY (`h_user_id`) 31 | ); 32 | 33 | CREATE TABLE `h_character_type` ( 34 | h_character_type_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 35 | h_action ENUM('create', 'update', 'delete'), 36 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 37 | `character_type_id` int(11) UNSIGNED NOT NULL, 38 | `name` varchar(255) NOT NULL, 39 | PRIMARY KEY (`h_character_type_id`) 40 | ); 41 | 42 | CREATE TABLE `h_character` ( 43 | h_character_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 44 | h_action ENUM('create', 'update', 'delete'), 45 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 46 | `character_id` int(11) UNSIGNED NOT NULL, 47 | `character_type_id` int(11) UNSIGNED NOT NULL, 48 | `name` varchar(255) NOT NULL, 49 | `alive` tinyint NOT NULL, 50 | `level` smallint NOT NULL, 51 | `xp` bigint NOT NULL, 52 | `money` bigint NOT NULL, 53 | PRIMARY KEY (`h_character_id`) 54 | ); 55 | 56 | CREATE TABLE `h_user_character` ( 57 | h_user_character_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 58 | h_action ENUM('create', 'update', 'delete'), 59 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 60 | `user_character_id` int(11) UNSIGNED NOT NULL, 61 | `user_id` int(11) UNSIGNED NOT NULL, 62 | `character_id` int(11) UNSIGNED NOT NULL, 63 | PRIMARY KEY (`h_user_character_id`) 64 | ); 65 | 66 | CREATE TABLE `h_attribute` ( 67 | h_attribute_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 68 | h_action ENUM('create', 'update', 'delete'), 69 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 70 | `attribute_id` int(11) UNSIGNED NOT NULL, 71 | `name` varchar(255) NOT NULL, 72 | `desc` varchar(255), 73 | PRIMARY KEY (`h_attribute_id`) 74 | ); 75 | 76 | CREATE TABLE `h_character_attribute` ( 77 | h_character_attribute_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 78 | h_action ENUM('create', 'update', 'delete'), 79 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 80 | `character_attribute_id` int(11) UNSIGNED NOT NULL, 81 | `character_id` int(11) UNSIGNED NOT NULL, 82 | `attribute_id` int(11) UNSIGNED NOT NULL, 83 | `value` bigint NOT NULL, 84 | PRIMARY KEY (`h_character_attribute_id`) 85 | ); 86 | 87 | CREATE TABLE `h_place` ( 88 | h_place_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 89 | h_action ENUM('create', 'update', 'delete'), 90 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 91 | `place_id` int(11) UNSIGNED NOT NULL, 92 | `name` varchar(255) NOT NULL, 93 | PRIMARY KEY (`h_place_id`) 94 | ); 95 | 96 | CREATE TABLE `h_location` ( 97 | h_location_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 98 | h_action ENUM('create', 'update', 'delete'), 99 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 100 | `location_id` int(11) UNSIGNED NOT NULL, 101 | `x` bigint NOT NULL, 102 | `y` bigint NOT NULL, 103 | `place_id` int(11) UNSIGNED NOT NULL, 104 | PRIMARY KEY (`h_location_id`) 105 | ); 106 | 107 | CREATE TABLE `h_character_location` ( 108 | h_character_location_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 109 | h_action ENUM('create', 'update', 'delete'), 110 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 111 | `character_location_id` int(11) UNSIGNED NOT NULL, 112 | `character_id` int(11) UNSIGNED NOT NULL, 113 | `location_id` int(11) UNSIGNED NOT NULL, 114 | PRIMARY KEY (`h_character_location_id`) 115 | ); 116 | 117 | CREATE TABLE `h_item_type` ( 118 | h_item_type_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 119 | h_action ENUM('create', 'update', 'delete'), 120 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 121 | `item_type_id` int(11) UNSIGNED NOT NULL, 122 | `name` varchar(255) NOT NULL, 123 | `desc` varchar(255), 124 | PRIMARY KEY (`h_item_type_id`) 125 | ); 126 | 127 | CREATE TABLE `h_item` ( 128 | h_item_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 129 | h_action ENUM('create', 'update', 'delete'), 130 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 131 | `item_id` int(11) UNSIGNED NOT NULL, 132 | `item_type_id` int(11) UNSIGNED NOT NULL, 133 | `name` varchar(255) NOT NULL, 134 | `required_level` smallint, 135 | `durability` tinyint NOT NULL, 136 | PRIMARY KEY (`h_item_id`) 137 | ); 138 | 139 | CREATE TABLE `h_item_attribute` ( 140 | h_item_attribute_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 141 | h_action ENUM('create', 'update', 'delete'), 142 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 143 | `item_attribute_id` int(11) UNSIGNED NOT NULL, 144 | `item_id` int(11) UNSIGNED NOT NULL, 145 | `attribute_id` int(11) UNSIGNED NOT NULL, 146 | `value` bigint NOT NULL, 147 | PRIMARY KEY (`h_item_attribute_id`) 148 | ); 149 | 150 | CREATE TABLE `h_item_location` ( 151 | h_item_location_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 152 | h_action ENUM('create', 'update', 'delete'), 153 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 154 | `item_location_id` int(11) UNSIGNED NOT NULL, 155 | `item_id` int(11) UNSIGNED NOT NULL, 156 | `location_id` int(11) UNSIGNED NOT NULL, 157 | PRIMARY KEY (`h_item_location_id`) 158 | ); 159 | 160 | CREATE TABLE `h_character_item` ( 161 | h_character_item_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 162 | h_action ENUM('create', 'update', 'delete'), 163 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 164 | `character_item_id` int(11) UNSIGNED NOT NULL, 165 | `character_id` int(11) UNSIGNED NOT NULL, 166 | `item_id` int(11) UNSIGNED NOT NULL, 167 | PRIMARY KEY (`h_character_item_id`) 168 | ); 169 | 170 | CREATE TABLE `h_equipment_slot` ( 171 | h_equipment_slot_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 172 | h_action ENUM('create', 'update', 'delete'), 173 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 174 | `equipment_slot_id` int(11) UNSIGNED NOT NULL, 175 | `name` varchar(255) NOT NULL, 176 | PRIMARY KEY (`h_equipment_slot_id`) 177 | ); 178 | 179 | CREATE TABLE `h_character_equipment` ( 180 | h_character_equipment_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 181 | h_action ENUM('create', 'update', 'delete'), 182 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 183 | `character_equipment_id` int(11) UNSIGNED NOT NULL, 184 | `equipment_slot_id` int(11) UNSIGNED NOT NULL, 185 | `character_id` int(11) UNSIGNED NOT NULL, 186 | `item_id` int(11) UNSIGNED NOT NULL, 187 | PRIMARY KEY (`h_character_equipment_id`) 188 | ); 189 | 190 | CREATE TABLE `h_class` ( 191 | h_class_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 192 | h_action ENUM('create', 'update', 'delete'), 193 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 194 | `class_id` int(11) UNSIGNED NOT NULL, 195 | `name` varchar(255) NOT NULL, 196 | PRIMARY KEY (`h_class_id`) 197 | ); 198 | 199 | CREATE TABLE `h_character_class` ( 200 | h_character_class_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 201 | h_action ENUM('create', 'update', 'delete'), 202 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 203 | `character_class_id` int(11) UNSIGNED NOT NULL, 204 | `character_id` int(11) UNSIGNED NOT NULL, 205 | `class_id` int(11) UNSIGNED NOT NULL, 206 | PRIMARY KEY (`h_character_class_id`) 207 | ); 208 | 209 | CREATE TABLE `h_ability_type` ( 210 | h_ability_type_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 211 | h_action ENUM('create', 'update', 'delete'), 212 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 213 | `ability_type_id` int(11) UNSIGNED NOT NULL, 214 | `name` varchar(255) NOT NULL, 215 | `desc` varchar(255), 216 | PRIMARY KEY (`h_ability_type_id`) 217 | ); 218 | 219 | CREATE TABLE `h_ability` ( 220 | h_ability_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 221 | h_action ENUM('create', 'update', 'delete'), 222 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 223 | `ability_id` int(11) UNSIGNED NOT NULL, 224 | `name` varchar(255) NOT NULL, 225 | `ability_type_id` int(11) UNSIGNED NOT NULL, 226 | `required_level` smallint, 227 | PRIMARY KEY (`h_ability_id`) 228 | ); 229 | 230 | CREATE TABLE `h_class_ability` ( 231 | h_class_ability_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 232 | h_action ENUM('create', 'update', 'delete'), 233 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 234 | `class_ability_id` int(11) UNSIGNED NOT NULL, 235 | `class_id` int(11) UNSIGNED NOT NULL, 236 | `ability_id` int(11) UNSIGNED NOT NULL, 237 | PRIMARY KEY (`h_class_ability_id`) 238 | ); 239 | 240 | CREATE TABLE `h_effect_type` ( 241 | h_effect_type_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 242 | h_action ENUM('create', 'update', 'delete'), 243 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 244 | `effect_type_id` int(11) UNSIGNED NOT NULL, 245 | `name` varchar(255) NOT NULL, 246 | `desc` varchar(255), 247 | PRIMARY KEY (`h_effect_type_id`) 248 | ); 249 | 250 | CREATE TABLE `h_status_effect` ( 251 | h_status_effect_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 252 | h_action ENUM('create', 'update', 'delete'), 253 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 254 | `status_effect_id` int(11) UNSIGNED NOT NULL, 255 | `name` varchar(255) NOT NULL, 256 | `effect_type_id` int(11) UNSIGNED NOT NULL, 257 | `duration` bigint, 258 | `desc` varchar(255), 259 | PRIMARY KEY (`h_status_effect_id`) 260 | ); 261 | 262 | CREATE TABLE `h_character_status_effect` ( 263 | h_character_status_effect_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 264 | h_action ENUM('create', 'update', 'delete'), 265 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 266 | `character_status_effect_id` int(11) UNSIGNED NOT NULL, 267 | `character_id` int(11) UNSIGNED NOT NULL, 268 | `status_effect_id` int(11) UNSIGNED NOT NULL, 269 | `date` TIMESTAMP, 270 | PRIMARY KEY (`h_character_status_effect_id`) 271 | ); 272 | 273 | CREATE TABLE `h_loot` ( 274 | h_loot_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 275 | h_action ENUM('create', 'update', 'delete'), 276 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 277 | `loot_id` int(11) UNSIGNED NOT NULL, 278 | `xp` bigint, 279 | `money` bigint, 280 | PRIMARY KEY (`h_loot_id`) 281 | ); 282 | 283 | CREATE TABLE `h_character_loot` ( 284 | h_character_loot_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 285 | h_action ENUM('create', 'update', 'delete'), 286 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 287 | `character_loot_id` int(11) UNSIGNED NOT NULL, 288 | `loot_id` int(11) UNSIGNED NOT NULL, 289 | `character_id` int(11) UNSIGNED NOT NULL, 290 | PRIMARY KEY (`h_character_loot_id`) 291 | ); 292 | 293 | CREATE TABLE `h_item_loot` ( 294 | h_item_loot_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 295 | h_action ENUM('create', 'update', 'delete'), 296 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 297 | `item_loot_id` int(11) UNSIGNED NOT NULL, 298 | `loot_id` int(11) UNSIGNED NOT NULL, 299 | `item_id` int(11) UNSIGNED NOT NULL, 300 | `drop_chance` FLOAT(4,4), 301 | PRIMARY KEY (`h_item_loot_id`) 302 | ); 303 | 304 | CREATE TABLE `h_entity_type` ( 305 | h_entity_type_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 306 | h_action ENUM('create', 'update', 'delete'), 307 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 308 | `entity_type_id` int(11) UNSIGNED NOT NULL, 309 | `name` varchar(255) NOT NULL, 310 | PRIMARY KEY (`h_entity_type_id`) 311 | ); 312 | 313 | CREATE TABLE `h_entity` ( 314 | h_entity_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 315 | h_action ENUM('create', 'update', 'delete'), 316 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 317 | `entity_id` int(11) UNSIGNED NOT NULL, 318 | `entity_type_id` int(11) UNSIGNED NOT NULL, 319 | `name` varchar(255) NOT NULL, 320 | `level` smallint, 321 | PRIMARY KEY (`h_entity_id`) 322 | ); 323 | 324 | CREATE TABLE `h_entity_attribute` ( 325 | h_entity_attribute_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 326 | h_action ENUM('create', 'update', 'delete'), 327 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 328 | `entity_attribute_id` int(11) UNSIGNED NOT NULL, 329 | `entity_id` int(11) UNSIGNED NOT NULL, 330 | `attribute_id` int(11) UNSIGNED NOT NULL, 331 | `value` bigint NOT NULL, 332 | PRIMARY KEY (`h_entity_attribute_id`) 333 | ); 334 | 335 | CREATE TABLE `h_entity_location` ( 336 | h_entity_location_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 337 | h_action ENUM('create', 'update', 'delete'), 338 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 339 | `entity_location_id` int(11) UNSIGNED NOT NULL, 340 | `entity_id` int(11) UNSIGNED NOT NULL, 341 | `location_id` int(11) UNSIGNED NOT NULL, 342 | PRIMARY KEY (`h_entity_location_id`) 343 | ); 344 | 345 | CREATE TABLE `h_entity_class` ( 346 | h_entity_class_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 347 | h_action ENUM('create', 'update', 'delete'), 348 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 349 | `entity_class_id` int(11) UNSIGNED NOT NULL, 350 | `entity_id` int(11) UNSIGNED NOT NULL, 351 | `class_id` int(11) UNSIGNED NOT NULL, 352 | PRIMARY KEY (`h_entity_class_id`) 353 | ); 354 | 355 | CREATE TABLE `h_entity_status_effect` ( 356 | h_entity_status_effect_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 357 | h_action ENUM('create', 'update', 'delete'), 358 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 359 | `entity_status_effect_id` int(11) UNSIGNED NOT NULL, 360 | `entity_id` int(11) UNSIGNED NOT NULL, 361 | `status_effect_id` int(11) UNSIGNED NOT NULL, 362 | `date` TIMESTAMP, 363 | PRIMARY KEY (`h_entity_status_effect_id`) 364 | ); 365 | 366 | CREATE TABLE `h_entity_loot` ( 367 | h_entity_loot_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 368 | h_action ENUM('create', 'update', 'delete'), 369 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 370 | `entity_loot_id` int(11) UNSIGNED NOT NULL, 371 | `loot_id` int(11) UNSIGNED NOT NULL, 372 | `entity_id` int(11) UNSIGNED NOT NULL, 373 | PRIMARY KEY (`h_entity_loot_id`) 374 | ); 375 | 376 | CREATE TABLE `h_faction` ( 377 | h_faction_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 378 | h_action ENUM('create', 'update', 'delete'), 379 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 380 | `faction_id` int(11) UNSIGNED NOT NULL, 381 | `name` varchar(255) NOT NULL, 382 | PRIMARY KEY (`h_faction_id`) 383 | ); 384 | 385 | CREATE TABLE `h_character_faction` ( 386 | h_character_faction_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 387 | h_action ENUM('create', 'update', 'delete'), 388 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 389 | `character_faction_id` int(11) UNSIGNED NOT NULL, 390 | `character_id` int(11) UNSIGNED NOT NULL, 391 | `faction_id` int(11) UNSIGNED NOT NULL, 392 | PRIMARY KEY (`h_character_faction_id`) 393 | ); 394 | 395 | CREATE TABLE `h_entity_faction` ( 396 | h_entity_faction_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 397 | h_action ENUM('create', 'update', 'delete'), 398 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 399 | `entity_faction_id` int(11) UNSIGNED NOT NULL, 400 | `entity_id` int(11) UNSIGNED NOT NULL, 401 | `faction_id` int(11) UNSIGNED NOT NULL, 402 | PRIMARY KEY (`h_entity_faction_id`) 403 | ); 404 | 405 | CREATE TABLE `h_rank` ( 406 | h_rank_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 407 | h_action ENUM('create', 'update', 'delete'), 408 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 409 | `guild_id` int(11) UNSIGNED NOT NULL, 410 | `name` varchar(255) NOT NULL, 411 | PRIMARY KEY (`h_rank_id`) 412 | ); 413 | 414 | CREATE TABLE `h_guild` ( 415 | h_guild_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 416 | h_action ENUM('create', 'update', 'delete'), 417 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 418 | `guild_id` int(11) UNSIGNED NOT NULL, 419 | `name` varchar(255) NOT NULL, 420 | PRIMARY KEY (`h_guild_id`) 421 | ); 422 | 423 | CREATE TABLE `h_guild_rank` ( 424 | h_guild_rank_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 425 | h_action ENUM('create', 'update', 'delete'), 426 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 427 | `guild_rank_id` int(11) UNSIGNED NOT NULL, 428 | `guild_id` int(11) UNSIGNED NOT NULL, 429 | `rank_id` int(11) UNSIGNED NOT NULL, 430 | PRIMARY KEY (`h_guild_rank_id`) 431 | ); 432 | 433 | CREATE TABLE `h_character_guild` ( 434 | h_character_guild_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 435 | h_action ENUM('create', 'update', 'delete'), 436 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 437 | `character_guild_id` int(11) UNSIGNED NOT NULL, 438 | `character_id` int(11) UNSIGNED NOT NULL, 439 | `guild_id` int(11) UNSIGNED NOT NULL, 440 | `guild_leader` tinyint, 441 | PRIMARY KEY (`h_character_guild_id`) 442 | ); 443 | 444 | CREATE TABLE `h_character_guild_rank` ( 445 | h_character_guild_rank_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 446 | h_action ENUM('create', 'update', 'delete'), 447 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 448 | `character_guild_rank_id` int(11) UNSIGNED NOT NULL, 449 | `character_id` int(11) UNSIGNED NOT NULL, 450 | `guild_rank_id` int(11) UNSIGNED NOT NULL, 451 | PRIMARY KEY (`h_character_guild_rank_id`) 452 | ); 453 | 454 | CREATE TABLE `h_party` ( 455 | h_party_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 456 | h_action ENUM('create', 'update', 'delete'), 457 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 458 | `party_id` int(11) UNSIGNED NOT NULL, 459 | PRIMARY KEY (`h_party_id`) 460 | ); 461 | 462 | CREATE TABLE `h_character_party` ( 463 | h_character_party_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 464 | h_action ENUM('create', 'update', 'delete'), 465 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 466 | `character_party_id` int(11) UNSIGNED NOT NULL, 467 | `character_id` int(11) UNSIGNED NOT NULL, 468 | `party_id` int(11) UNSIGNED NOT NULL, 469 | `party_leader` tinyint, 470 | PRIMARY KEY (`h_character_party_id`) 471 | ); 472 | 473 | CREATE TABLE `h_title` ( 474 | h_title_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 475 | h_action ENUM('create', 'update', 'delete'), 476 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 477 | `title_id` int(11) UNSIGNED NOT NULL, 478 | `name` varchar(255) NOT NULL, 479 | PRIMARY KEY (`h_title_id`) 480 | ); 481 | 482 | CREATE TABLE `h_character_title` ( 483 | h_character_title_id bigint UNSIGNED NOT NULL AUTO_INCREMENT, 484 | h_action ENUM('create', 'update', 'delete'), 485 | h_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 486 | `character_title_id` int(11) UNSIGNED NOT NULL, 487 | `character_id` int(11) UNSIGNED NOT NULL, 488 | `title_id` int(11) UNSIGNED NOT NULL, 489 | PRIMARY KEY (`h_character_title_id`) 490 | ); 491 | -------------------------------------------------------------------------------- /create_tables.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `conf` ( 2 | `conf_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `name` varchar(255) NOT NULL, 4 | `value` varchar(255), 5 | PRIMARY KEY (`conf_id`), 6 | CONSTRAINT `uk_name` UNIQUE (`name`) 7 | ); 8 | 9 | CREATE TABLE `user_type` ( 10 | `user_type_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 11 | `name` varchar(255) NOT NULL, 12 | PRIMARY KEY (`user_type_id`) 13 | ); 14 | 15 | INSERT INTO `user_type` (`name`) VALUES ('admin'); 16 | INSERT INTO `user_type` (`name`) VALUES ('moderator'); 17 | INSERT INTO `user_type` (`name`) VALUES ('player'); 18 | INSERT INTO `user_type` (`name`) VALUES ('spectator'); 19 | 20 | CREATE TABLE `user` ( 21 | `user_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 22 | `user_type_id` int(11) UNSIGNED NOT NULL, 23 | `first_name` varchar(255) NOT NULL, 24 | `last_name` varchar(255) NOT NULL, 25 | `email` varchar(255) NOT NULL, 26 | `password` varchar(255) NOT NULL, 27 | PRIMARY KEY (`user_id`), 28 | CONSTRAINT `fk_user_user_type_id` FOREIGN KEY (`user_type_id`) REFERENCES `user_type`(`user_type_id`) ON DELETE CASCADE ON UPDATE CASCADE 29 | ); 30 | 31 | CREATE TABLE `character_type` ( 32 | `character_type_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 33 | `name` varchar(255) NOT NULL, 34 | PRIMARY KEY (`character_type_id`) 35 | ); 36 | 37 | INSERT INTO `character_type` (`name`) VALUES ('player'); 38 | INSERT INTO `character_type` (`name`) VALUES ('non-playable'); 39 | 40 | CREATE TABLE `character` ( 41 | `character_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 42 | `character_type_id` int(11) UNSIGNED NOT NULL, 43 | `name` varchar(255) NOT NULL, 44 | `alive` tinyint NOT NULL, 45 | `level` smallint NOT NULL, 46 | `xp` bigint NOT NULL, 47 | `money` bigint NOT NULL, 48 | PRIMARY KEY (`character_id`), 49 | CONSTRAINT `fk_character_character_type_id` FOREIGN KEY (`character_type_id`) REFERENCES `character_type`(`character_type_id`) ON DELETE CASCADE ON UPDATE CASCADE 50 | ); 51 | 52 | CREATE TABLE `user_character` ( 53 | `user_character_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 54 | `user_id` int(11) UNSIGNED NOT NULL, 55 | `character_id` int(11) UNSIGNED NOT NULL, 56 | PRIMARY KEY (`user_character_id`), 57 | CONSTRAINT `uk_user_id_character_id` UNIQUE (`user_id`, `character_id`), 58 | CONSTRAINT `fk_user_character_user_id` FOREIGN KEY (`user_id`) REFERENCES `user`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE, 59 | CONSTRAINT `fk_user_character_character_id` FOREIGN KEY (`character_id`) REFERENCES `character`(`character_id`) ON DELETE CASCADE ON UPDATE CASCADE 60 | ); 61 | 62 | CREATE TABLE `attribute` ( 63 | `attribute_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 64 | `name` varchar(255) NOT NULL, 65 | `desc` varchar(255), 66 | PRIMARY KEY (`attribute_id`) 67 | ); 68 | 69 | INSERT INTO `attribute` (`name`, `desc`) VALUES ('strength', 'A measure of how physically strong a character is.'); 70 | INSERT INTO `attribute` (`name`, `desc`) VALUES ('constitution', 'A measure of how resilient a character is.'); 71 | INSERT INTO `attribute` (`name`, `desc`) VALUES ('dexterity', 'A measure of how agile a character is.'); 72 | INSERT INTO `attribute` (`name`, `desc`) VALUES ('intelligence', 'A measure of a character''s problem-solving ability.'); 73 | INSERT INTO `attribute` (`name`, `desc`) VALUES ('charisma', 'A measure of a character''s social skills, and sometimes their physical appearance.'); 74 | INSERT INTO `attribute` (`name`, `desc`) VALUES ('wisdom', 'A measure of a character''s common sense and/or spirituality.'); 75 | INSERT INTO `attribute` (`name`, `desc`) VALUES ('willpower', 'A measure of the character''s mental resistance.'); 76 | INSERT INTO `attribute` (`name`, `desc`) VALUES ('perception', 'A measure of a character''s openness to their surroundings.'); 77 | INSERT INTO `attribute` (`name`, `desc`) VALUES ('luck', 'A measure of a character having chance to favor him or her.'); 78 | INSERT INTO `attribute` (`name`, `desc`) VALUES ('damage', 'A measure to inflict damage'); 79 | 80 | CREATE TABLE `character_attribute` ( 81 | `character_attribute_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 82 | `character_id` int(11) UNSIGNED NOT NULL, 83 | `attribute_id` int(11) UNSIGNED NOT NULL, 84 | `value` bigint NOT NULL, 85 | PRIMARY KEY (`character_attribute_id`), 86 | CONSTRAINT `uk_character_id_attribute_id` UNIQUE (`character_id`, `attribute_id`), 87 | CONSTRAINT `fk_character_attribute_character_id` FOREIGN KEY (`character_id`) REFERENCES `character`(`character_id`) ON DELETE CASCADE ON UPDATE CASCADE, 88 | CONSTRAINT `fk_character_attribute_attribute_id` FOREIGN KEY (`attribute_id`) REFERENCES `attribute`(`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE 89 | ); 90 | 91 | CREATE TABLE `place` ( 92 | `place_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 93 | `name` varchar(255) NOT NULL, 94 | PRIMARY KEY (`place_id`) 95 | ); 96 | 97 | CREATE TABLE `location` ( 98 | `location_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 99 | `x` bigint NOT NULL, 100 | `y` bigint NOT NULL, 101 | `place_id` int(11) UNSIGNED NOT NULL, 102 | PRIMARY KEY (`location_id`), 103 | CONSTRAINT `uk_x_y` UNIQUE (`x`, `y`), 104 | CONSTRAINT `fk_location_place_id` FOREIGN KEY (`place_id`) REFERENCES `place`(`place_id`) ON DELETE CASCADE ON UPDATE CASCADE 105 | ); 106 | 107 | CREATE TABLE `character_location` ( 108 | `character_location_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 109 | `character_id` int(11) UNSIGNED NOT NULL, 110 | `location_id` int(11) UNSIGNED NOT NULL, 111 | PRIMARY KEY (`character_location_id`), 112 | CONSTRAINT `uk_character_id` UNIQUE (`character_id`), 113 | CONSTRAINT `fk_character_location_character_id` FOREIGN KEY (`character_id`) REFERENCES `character`(`character_id`) ON DELETE CASCADE ON UPDATE CASCADE, 114 | CONSTRAINT `fk_character_location_location_id` FOREIGN KEY (`location_id`) REFERENCES `location`(`location_id`) ON DELETE CASCADE ON UPDATE CASCADE 115 | ); 116 | 117 | CREATE TABLE `item_type` ( 118 | `item_type_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 119 | `name` varchar(255) NOT NULL, 120 | `desc` varchar(255), 121 | PRIMARY KEY (`item_type_id`) 122 | ); 123 | 124 | CREATE TABLE `item` ( 125 | `item_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 126 | `item_type_id` int(11) UNSIGNED NOT NULL, 127 | `name` varchar(255) NOT NULL, 128 | `required_level` smallint, 129 | `durability` tinyint NOT NULL, 130 | PRIMARY KEY (`item_id`), 131 | CONSTRAINT `fk_item_item_type_id` FOREIGN KEY (`item_type_id`) REFERENCES `item_type`(`item_type_id`) ON DELETE CASCADE ON UPDATE CASCADE 132 | ); 133 | 134 | CREATE TABLE `item_attribute` ( 135 | `item_attribute_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 136 | `item_id` int(11) UNSIGNED NOT NULL, 137 | `attribute_id` int(11) UNSIGNED NOT NULL, 138 | `value` bigint NOT NULL, 139 | PRIMARY KEY (`item_attribute_id`), 140 | CONSTRAINT `uk_item_id_attribute_id` UNIQUE (`item_id`, `attribute_id`), 141 | CONSTRAINT `fk_item_attribute_item_id` FOREIGN KEY (`item_id`) REFERENCES `item`(`item_id`) ON DELETE CASCADE ON UPDATE CASCADE, 142 | CONSTRAINT `fk_item_attribute_attribute_id` FOREIGN KEY (`attribute_id`) REFERENCES `attribute`(`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE 143 | ); 144 | 145 | CREATE TABLE `item_location` ( 146 | `item_location_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 147 | `item_id` int(11) UNSIGNED NOT NULL, 148 | `location_id` int(11) UNSIGNED NOT NULL, 149 | PRIMARY KEY (`item_location_id`), 150 | CONSTRAINT `uk_item_id` UNIQUE (`item_id`), 151 | CONSTRAINT `fk_item_location_item_id` FOREIGN KEY (`item_id`) REFERENCES `item`(`item_id`) ON DELETE CASCADE ON UPDATE CASCADE, 152 | CONSTRAINT `fk_item_location_location_id` FOREIGN KEY (`location_id`) REFERENCES `location`(`location_id`) ON DELETE CASCADE ON UPDATE CASCADE 153 | ); 154 | 155 | CREATE TABLE `character_item` ( 156 | `character_item_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 157 | `character_id` int(11) UNSIGNED NOT NULL, 158 | `item_id` int(11) UNSIGNED NOT NULL, 159 | PRIMARY KEY (`character_item_id`), 160 | CONSTRAINT `uk_character_id_item_id` UNIQUE (`character_id`, `item_id`), 161 | CONSTRAINT `fk_character_item_character_id` FOREIGN KEY (`character_id`) REFERENCES `character`(`character_id`) ON DELETE CASCADE ON UPDATE CASCADE, 162 | CONSTRAINT `fk_character_item_item_id` FOREIGN KEY (`item_id`) REFERENCES `item`(`item_id`) ON DELETE CASCADE ON UPDATE CASCADE 163 | ); 164 | 165 | CREATE TABLE `equipment_slot` ( 166 | `equipment_slot_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 167 | `name` varchar(255) NOT NULL, 168 | PRIMARY KEY (`equipment_slot_id`), 169 | CONSTRAINT `uk_name` UNIQUE (`name`) 170 | ); 171 | 172 | INSERT INTO `equipment_slot` (`name`) VALUES ('head'); 173 | INSERT INTO `equipment_slot` (`name`) VALUES ('shoulder'); 174 | INSERT INTO `equipment_slot` (`name`) VALUES ('chest'); 175 | INSERT INTO `equipment_slot` (`name`) VALUES ('back'); 176 | INSERT INTO `equipment_slot` (`name`) VALUES ('wrist'); 177 | INSERT INTO `equipment_slot` (`name`) VALUES ('hands'); 178 | INSERT INTO `equipment_slot` (`name`) VALUES ('waist'); 179 | INSERT INTO `equipment_slot` (`name`) VALUES ('leg'); 180 | INSERT INTO `equipment_slot` (`name`) VALUES ('feet'); 181 | INSERT INTO `equipment_slot` (`name`) VALUES ('neck'); 182 | INSERT INTO `equipment_slot` (`name`) VALUES ('ears'); 183 | INSERT INTO `equipment_slot` (`name`) VALUES ('ring'); 184 | INSERT INTO `equipment_slot` (`name`) VALUES ('main_hand'); 185 | INSERT INTO `equipment_slot` (`name`) VALUES ('off_hand'); 186 | 187 | CREATE TABLE `character_equipment` ( 188 | `character_equipment_id` int(11) UNSIGNED NOT NULL, 189 | `equipment_slot_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 190 | `character_id` int(11) UNSIGNED NOT NULL, 191 | `item_id` int(11) UNSIGNED NOT NULL, 192 | PRIMARY KEY (`equipment_slot_id`), 193 | CONSTRAINT `uk_equipment_slot_id_character_id` UNIQUE (`equipment_slot_id`, `character_id`), 194 | CONSTRAINT `fk_character_equipment_equipment_slot_id` FOREIGN KEY (`equipment_slot_id`) REFERENCES `equipment_slot`(`equipment_slot_id`) ON DELETE CASCADE ON UPDATE CASCADE, 195 | CONSTRAINT `fk_character_equipment_character_id` FOREIGN KEY (`character_id`) REFERENCES `character`(`character_id`) ON DELETE CASCADE ON UPDATE CASCADE, 196 | CONSTRAINT `fk_character_equipment_item_id` FOREIGN KEY (`item_id`) REFERENCES `item`(`item_id`) ON DELETE CASCADE ON UPDATE CASCADE 197 | ); 198 | 199 | CREATE TABLE `class` ( 200 | `class_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 201 | `name` varchar(255) NOT NULL, 202 | PRIMARY KEY (`class_id`), 203 | CONSTRAINT `uk_name` UNIQUE (`name`) 204 | ); 205 | 206 | CREATE TABLE `character_class` ( 207 | `character_class_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 208 | `character_id` int(11) UNSIGNED NOT NULL, 209 | `class_id` int(11) UNSIGNED NOT NULL, 210 | PRIMARY KEY (`character_class_id`), 211 | CONSTRAINT `uk_character_id` UNIQUE (`character_id`), 212 | CONSTRAINT `fk_character_class_character_id` FOREIGN KEY (`character_id`) REFERENCES `character`(`character_id`) ON DELETE CASCADE ON UPDATE CASCADE, 213 | CONSTRAINT `fk_character_class_class_id` FOREIGN KEY (`class_id`) REFERENCES `class`(`class_id`) ON DELETE CASCADE ON UPDATE CASCADE 214 | ); 215 | 216 | CREATE TABLE `ability_type` ( 217 | `ability_type_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 218 | `name` varchar(255) NOT NULL, 219 | `desc` varchar(255), 220 | PRIMARY KEY (`ability_type_id`) 221 | ); 222 | 223 | CREATE TABLE `ability` ( 224 | `ability_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 225 | `name` varchar(255) NOT NULL, 226 | `ability_type_id` int(11) UNSIGNED NOT NULL, 227 | `required_level` smallint, 228 | PRIMARY KEY (`ability_id`), 229 | CONSTRAINT `fk_ability_ability_type_id` FOREIGN KEY (`ability_type_id`) REFERENCES `ability_type`(`ability_type_id`) ON DELETE CASCADE ON UPDATE CASCADE 230 | ); 231 | 232 | CREATE TABLE `class_ability` ( 233 | `class_ability_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 234 | `class_id` int(11) UNSIGNED NOT NULL, 235 | `ability_id` int(11) UNSIGNED NOT NULL, 236 | PRIMARY KEY (`class_ability_id`), 237 | CONSTRAINT `uk_class_id_ability_id` UNIQUE (`class_id`, `ability_id`), 238 | CONSTRAINT `fk_class_ability_class_id` FOREIGN KEY (`class_id`) REFERENCES `class`(`class_id`) ON DELETE CASCADE ON UPDATE CASCADE, 239 | CONSTRAINT `fk_class_ability_ability_id` FOREIGN KEY (`ability_id`) REFERENCES `ability`(`ability_id`) ON DELETE CASCADE ON UPDATE CASCADE 240 | ); 241 | 242 | CREATE TABLE `effect_type` ( 243 | `effect_type_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 244 | `name` varchar(255) NOT NULL, 245 | `desc` varchar(255), 246 | PRIMARY KEY (`effect_type_id`) 247 | ); 248 | 249 | INSERT INTO `effect_type` (`name`, `desc`) VALUES ('buff', 'A temporary benefit to a character’s attributes'); 250 | INSERT INTO `effect_type` (`name`, `desc`) VALUES ('debuff', 'A temporary hindrance to a character’s attributes'); 251 | 252 | CREATE TABLE `status_effect` ( 253 | `status_effect_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 254 | `name` varchar(255) NOT NULL, 255 | `effect_type_id` int(11) UNSIGNED NOT NULL, 256 | `duration` bigint, 257 | `desc` varchar(255), 258 | PRIMARY KEY (`status_effect_id`), 259 | CONSTRAINT `fk_status_effect_effect_type_id` FOREIGN KEY (`effect_type_id`) REFERENCES `effect_type`(`effect_type_id`) ON DELETE CASCADE ON UPDATE CASCADE 260 | ); 261 | 262 | CREATE TABLE `character_status_effect` ( 263 | `character_status_effect_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 264 | `character_id` int(11) UNSIGNED NOT NULL, 265 | `status_effect_id` int(11) UNSIGNED NOT NULL, 266 | `date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 267 | PRIMARY KEY (`character_status_effect_id`), 268 | CONSTRAINT `fk_character_status_effect_status_effect_id` FOREIGN KEY (`status_effect_id`) REFERENCES `status_effect`(`status_effect_id`) ON DELETE CASCADE ON UPDATE CASCADE, 269 | CONSTRAINT `fk_character_status_effect_character_id` FOREIGN KEY (`character_id`) REFERENCES `character`(`character_id`) ON DELETE CASCADE ON UPDATE CASCADE 270 | ); 271 | 272 | CREATE TABLE `loot` ( 273 | `loot_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 274 | `xp` bigint, 275 | `money` bigint, 276 | PRIMARY KEY (`loot_id`) 277 | ); 278 | 279 | CREATE TABLE `character_loot` ( 280 | `character_loot_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 281 | `loot_id` int(11) UNSIGNED NOT NULL, 282 | `character_id` int(11) UNSIGNED NOT NULL, 283 | PRIMARY KEY (`character_loot_id`), 284 | CONSTRAINT `fk_character_loot_loot_id` FOREIGN KEY (`loot_id`) REFERENCES `loot`(`loot_id`) ON DELETE CASCADE ON UPDATE CASCADE, 285 | CONSTRAINT `fk_character_loot_character_id` FOREIGN KEY (`character_id`) REFERENCES `character`(`character_id`) ON DELETE CASCADE ON UPDATE CASCADE 286 | ); 287 | 288 | CREATE TABLE `item_loot` ( 289 | `item_loot_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 290 | `loot_id` int(11) UNSIGNED NOT NULL, 291 | `item_id` int(11) UNSIGNED NOT NULL, 292 | `drop_chance` FLOAT(4,4), 293 | PRIMARY KEY (`item_loot_id`), 294 | CONSTRAINT `fk_item_loot_loot_id` FOREIGN KEY (`loot_id`) REFERENCES `loot`(`loot_id`) ON DELETE CASCADE ON UPDATE CASCADE, 295 | CONSTRAINT `fk_item_loot_item_id` FOREIGN KEY (`item_id`) REFERENCES `item`(`item_id`) ON DELETE CASCADE ON UPDATE CASCADE 296 | ); 297 | 298 | CREATE TABLE `entity_type` ( 299 | `entity_type_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 300 | `name` varchar(255) NOT NULL, 301 | PRIMARY KEY (`entity_type_id`) 302 | ); 303 | 304 | CREATE TABLE `entity` ( 305 | `entity_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 306 | `entity_type_id` int(11) UNSIGNED NOT NULL, 307 | `name` varchar(255) NOT NULL, 308 | `level` smallint, 309 | PRIMARY KEY (`entity_id`), 310 | CONSTRAINT `fk_entity_entity_type_id` FOREIGN KEY (`entity_type_id`) REFERENCES `entity_type`(`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE 311 | ); 312 | 313 | CREATE TABLE `entity_attribute` ( 314 | `entity_attribute_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 315 | `entity_id` int(11) UNSIGNED NOT NULL, 316 | `attribute_id` int(11) UNSIGNED NOT NULL, 317 | `value` bigint NOT NULL, 318 | PRIMARY KEY (`entity_attribute_id`), 319 | CONSTRAINT `uk_entity_id_attribute_id` UNIQUE (`entity_id`, `attribute_id`), 320 | CONSTRAINT `fk_entity_attribute_entity_id` FOREIGN KEY (`entity_id`) REFERENCES `entity`(`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE, 321 | CONSTRAINT `fk_entity_attribute_attribute_id` FOREIGN KEY (`attribute_id`) REFERENCES `attribute`(`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE 322 | ); 323 | 324 | CREATE TABLE `entity_location` ( 325 | `entity_location_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 326 | `entity_id` int(11) UNSIGNED NOT NULL, 327 | `location_id` int(11) UNSIGNED NOT NULL, 328 | PRIMARY KEY (`entity_location_id`), 329 | CONSTRAINT `uk_entity_id` UNIQUE (`entity_id`), 330 | CONSTRAINT `fk_entity_location_entity_id` FOREIGN KEY (`entity_id`) REFERENCES `entity`(`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE, 331 | CONSTRAINT `fk_entity_location_location_id` FOREIGN KEY (`location_id`) REFERENCES `location`(`location_id`) ON DELETE CASCADE ON UPDATE CASCADE 332 | ); 333 | 334 | CREATE TABLE `entity_class` ( 335 | `entity_class_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 336 | `entity_id` int(11) UNSIGNED NOT NULL, 337 | `class_id` int(11) UNSIGNED NOT NULL, 338 | PRIMARY KEY (`entity_class_id`), 339 | CONSTRAINT `uk_entity_id` UNIQUE (`entity_id`), 340 | CONSTRAINT `fk_entity_class_entity_id` FOREIGN KEY (`entity_id`) REFERENCES `entity`(`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE, 341 | CONSTRAINT `fk_entity_class_class_id` FOREIGN KEY (`class_id`) REFERENCES `class`(`class_id`) ON DELETE CASCADE ON UPDATE CASCADE 342 | ); 343 | 344 | CREATE TABLE `entity_status_effect` ( 345 | `entity_status_effect_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 346 | `entity_id` int(11) UNSIGNED NOT NULL, 347 | `status_effect_id` int(11) UNSIGNED NOT NULL, 348 | `date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 349 | PRIMARY KEY (`entity_status_effect_id`), 350 | CONSTRAINT `fk_entity_status_effect_status_effect_id` FOREIGN KEY (`status_effect_id`) REFERENCES `status_effect`(`status_effect_id`) ON DELETE CASCADE ON UPDATE CASCADE, 351 | CONSTRAINT `fk_entity_status_effect_entity_id` FOREIGN KEY (`entity_id`) REFERENCES `entity`(`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE 352 | ); 353 | 354 | CREATE TABLE `entity_loot` ( 355 | `entity_loot_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 356 | `loot_id` int(11) UNSIGNED NOT NULL, 357 | `entity_id` int(11) UNSIGNED NOT NULL, 358 | PRIMARY KEY (`entity_loot_id`), 359 | CONSTRAINT `fk_entity_loot_loot_id` FOREIGN KEY (`loot_id`) REFERENCES `loot`(`loot_id`) ON DELETE CASCADE ON UPDATE CASCADE, 360 | CONSTRAINT `fk_entity_loot_entity_id` FOREIGN KEY (`entity_id`) REFERENCES `entity`(`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE 361 | ); 362 | 363 | CREATE TABLE `faction` ( 364 | `faction_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 365 | `name` varchar(255) NOT NULL, 366 | PRIMARY KEY (`faction_id`) 367 | ); 368 | 369 | CREATE TABLE `character_faction` ( 370 | `character_faction_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 371 | `character_id` int(11) UNSIGNED NOT NULL, 372 | `faction_id` int(11) UNSIGNED NOT NULL, 373 | PRIMARY KEY (`character_faction_id`), 374 | CONSTRAINT `fk_character_faction_character_id` FOREIGN KEY (`character_id`) REFERENCES `character`(`character_id`) ON DELETE CASCADE ON UPDATE CASCADE, 375 | CONSTRAINT `fk_character_faction_faction_id` FOREIGN KEY (`faction_id`) REFERENCES `faction`(`faction_id`) ON DELETE CASCADE ON UPDATE CASCADE 376 | ); 377 | 378 | CREATE TABLE `entity_faction` ( 379 | `entity_faction_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 380 | `entity_id` int(11) UNSIGNED NOT NULL, 381 | `faction_id` int(11) UNSIGNED NOT NULL, 382 | PRIMARY KEY (`entity_faction_id`), 383 | CONSTRAINT `fk_entity_faction_entity_id` FOREIGN KEY (`entity_id`) REFERENCES `entity`(`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE, 384 | CONSTRAINT `fk_entity_faction_faction_id` FOREIGN KEY (`faction_id`) REFERENCES `faction`(`faction_id`) ON DELETE CASCADE ON UPDATE CASCADE 385 | ); 386 | 387 | CREATE TABLE `rank` ( 388 | `rank_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 389 | `name` varchar(255) NOT NULL, 390 | PRIMARY KEY (`rank_id`) 391 | ); 392 | 393 | CREATE TABLE `guild` ( 394 | `guild_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 395 | `name` varchar(255) NOT NULL, 396 | PRIMARY KEY (`guild_id`) 397 | ); 398 | 399 | CREATE TABLE `guild_rank` ( 400 | `guild_rank_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 401 | `guild_id` int(11) UNSIGNED NOT NULL, 402 | `rank_id` int(11) UNSIGNED NOT NULL, 403 | PRIMARY KEY (`guild_rank_id`), 404 | CONSTRAINT `uk_guild_id_rank_id` UNIQUE (`guild_id`, `rank_id`), 405 | CONSTRAINT `fk_guild_rank_guild_id` FOREIGN KEY (`guild_id`) REFERENCES `guild`(`guild_id`) ON DELETE CASCADE ON UPDATE CASCADE, 406 | CONSTRAINT `fk_guild_rank_rank_id` FOREIGN KEY (`rank_id`) REFERENCES `rank`(`rank_id`) ON DELETE CASCADE ON UPDATE CASCADE 407 | ); 408 | 409 | CREATE TABLE `character_guild` ( 410 | `character_guild_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 411 | `character_id` int(11) UNSIGNED NOT NULL, 412 | `guild_id` int(11) UNSIGNED NOT NULL, 413 | `guild_leader` tinyint, 414 | PRIMARY KEY (`character_guild_id`), 415 | CONSTRAINT `uk_guild_id_guild_leader` UNIQUE (`guild_id`, `guild_leader`), 416 | CONSTRAINT `fk_character_guild_character_id` FOREIGN KEY (`character_id`) REFERENCES `character`(`character_id`) ON DELETE CASCADE ON UPDATE CASCADE, 417 | CONSTRAINT `fk_character_guild_guild_id` FOREIGN KEY (`guild_id`) REFERENCES `guild`(`guild_id`) ON DELETE CASCADE ON UPDATE CASCADE 418 | ); 419 | 420 | CREATE TABLE `character_guild_rank` ( 421 | `character_guild_rank_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 422 | `character_id` int(11) UNSIGNED NOT NULL, 423 | `guild_rank_id` int(11) UNSIGNED NOT NULL, 424 | PRIMARY KEY (`character_guild_rank_id`), 425 | CONSTRAINT `uk_character_id_guild_rank_id` UNIQUE (`character_id`, `guild_rank_id`), 426 | CONSTRAINT `fk_character_guild_rank_character_id` FOREIGN KEY (`character_id`) REFERENCES `character`(`character_id`) ON DELETE CASCADE ON UPDATE CASCADE, 427 | CONSTRAINT `fk_character_guild_rank_guild_rank_id` FOREIGN KEY (`guild_rank_id`) REFERENCES `guild_rank`(`guild_rank_id`) ON DELETE CASCADE ON UPDATE CASCADE 428 | ); 429 | 430 | CREATE TABLE `party` ( 431 | `party_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 432 | PRIMARY KEY (`party_id`) 433 | ); 434 | 435 | CREATE TABLE `character_party` ( 436 | `character_party_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 437 | `character_id` int(11) UNSIGNED NOT NULL, 438 | `party_id` int(11) UNSIGNED NOT NULL, 439 | `party_leader` tinyint, 440 | PRIMARY KEY (`character_party_id`), 441 | CONSTRAINT `uk_character_id` UNIQUE (`character_id`), 442 | CONSTRAINT `uk_party_id_party_leader` UNIQUE (`party_id`, `party_leader`), 443 | CONSTRAINT `fk_character_party_character_id` FOREIGN KEY (`character_id`) REFERENCES `character`(`character_id`) ON DELETE CASCADE ON UPDATE CASCADE, 444 | CONSTRAINT `fk_character_party_party_id` FOREIGN KEY (`party_id`) REFERENCES `party`(`party_id`) ON DELETE CASCADE ON UPDATE CASCADE 445 | ); 446 | 447 | CREATE TABLE `title` ( 448 | `title_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 449 | `name` varchar(255) NOT NULL, 450 | PRIMARY KEY (`title_id`) 451 | ); 452 | 453 | CREATE TABLE `character_title` ( 454 | `character_title_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 455 | `character_id` int(11) UNSIGNED NOT NULL, 456 | `title_id` int(11) UNSIGNED NOT NULL, 457 | PRIMARY KEY (`character_title_id`), 458 | CONSTRAINT `fk_character_title_character_id` FOREIGN KEY (`character_id`) REFERENCES `character`(`character_id`) ON DELETE CASCADE ON UPDATE CASCADE, 459 | CONSTRAINT `fk_character_title_title_id` FOREIGN KEY (`title_id`) REFERENCES `title`(`title_id`) ON DELETE CASCADE ON UPDATE CASCADE 460 | ); 461 | --------------------------------------------------------------------------------