![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Or, better yet, is there a way that I can make the subjects "id" to AUTOINCREMENT without being a unique key; maybe, if "id" and "forum_name" combined were unique? This would be best if it's possible, so that any bookmarks to current id's would still work. |
#3
| |||
| |||
|
|
On Tuesday, November 29, 2011 10:17:47 PM UTC-5, Jason C wrote: Or, better yet, is there a way that I can make the subjects "id" to AUTOINCREMENT without being a unique key; maybe, if "id" and "forum_name" combined were unique? This would be best if it's possible, so that any bookmarks to current id's would still work. Update: it DOES look like I can create a PRIMARY on 2 columns. If I understand correctly, doing so allows me to have duplicate IDs, as long as the second column makes that ID unique. So, I can have: id: 1234 forum_name: ford id: 1234 forum_name: chevy But, it's worth knowing that the AUTO_INCREMENT for subsequent row inserts is going to be based on the highest number in the row, not based on the group. So, if the current highest ID for "ford" is 1234, and the highest ID for "chevy" is 150000, and then I merge the two tables, then the next ID for ford is going to be 150001 (not 1235). For the record, to ensure that the database runs nice and fast, I'll be using a cron that runs daily (at midnight) to move rows from the "posts" table that are more than 90 days old to a separate "archive" table. I don't think there's a way to do this without using a PHP script, but I'm open to suggestions. Can you guys confirm if I am correct on all of this? |
#4
| |||
| |||
|
|
Autoincrement is based on the table. MySQL has no idea what a "board" is. But you're going to run into all kinds of problems trying to maintain your database like this. |
|
First of all, create a table - "board". It will have (at least) two columns - an id and board name (potentially others like description, etc.). Now create a table "subjects" and one "posts". "Subjects" will be the same as before, only with the addition of a "board" column. "Posts" will be identical to what you had before. Now create a script which goes through and reads each of the rows in your old tables and writes them to the new tables. You'll get a new key for each row; you'll have to use the new "subjects" key in your "posts" table. It's a lot more work, but I think it will be worth it in the long run. |
#5
| |||
| |||
|
|
On Wednesday, November 30, 2011 9:12:52 AM UTC-5, Jerry Stuckle wrote: Autoincrement is based on the table. MySQL has no idea what a "board" is. But you're going to run into all kinds of problems trying to maintain your database like this. Can you give me an idea of the type of problems I should expect? I set up some of my less active features like this awhile back, and haven't had any technical problems, but the message boards are infinitely more active than those. |
.|
First of all, create a table - "board". It will have (at least) two columns - an id and board name (potentially others like description, etc.). Now create a table "subjects" and one "posts". "Subjects" will be the same as before, only with the addition of a "board" column. "Posts" will be identical to what you had before. Now create a script which goes through and reads each of the rows in your old tables and writes them to the new tables. You'll get a new key for each row; you'll have to use the new "subjects" key in your "posts" table. It's a lot more work, but I think it will be worth it in the long run. I'm not sure that I understand, what would be the purpose of the "board" table? |
![]() |
| Thread Tools | |
| Display Modes | |
| |