0

Is the below a good or bad idea? I have multiple tables for different node types. Each table has an auto-increment ID for that nodeType. So that every node type has a truly unique ID each nodeType would have a range of IDs. eg.

table 1, ID auto increment from 0-1000000000
table 2, ID auto increment from 1000000000-2000000000
table 3, ID auto increment from 2000000000-3000000000

I know the above could also be solved with an extra nodeType table and a JOIN, however other than the fact that there would be a limit to the ID ranges is the above a bad idea?.. thanks to any responders.

jon
  • 1,429
  • 1
  • 23
  • 40
  • What is the structure of these three tables? Are they different or the same? If they are all related with a similar structure, it doesn't make much sense to split them into three tables. You need to think how you would reference these later on, how are you going to create a foreign key that relies on `ID` if the `ID` is potentially in three or more different tables? – Devon Bessemer Apr 19 '15 at 16:52

1 Answers1

0

https://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

https://stackoverflow.com/a/1485685/4421474

Just set start value:

ALTER TABLE `table 1` AUTO_INCREMENT=0;

ALTER TABLE `table 2` AUTO_INCREMENT=1000000001;

ALTER TABLE `table 3` AUTO_INCREMENT=2000000001;
Community
  • 1
  • 1
Alex
  • 16,739
  • 1
  • 28
  • 51