Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Help in designing a Mysql table
07-13-2011, 10:56 PM #1
- Join Date
- Jul 2011
- Thanked 0 Times in 0 Posts
Help in designing a Mysql table
I have two tables: t1 and t2. t1 is the parent table, and t2 is the child.
and there are around 500 records already in it.
I want to create a parent table t1 which will have a fields
id needs to auto increment for all the 500 rows in t2, and the remaining fields title, http and recordno should get the values from t2. So parent table t1 should be updated with 500 rows of t2 and in future if we insert new values in t2 these should also be updated in t1.
I might have another child tables like t2 and i want t1 as a index for all these table with an unique id and t2 has around 80 fields while t1 will only have 4 unique fields.
07-13-2011, 11:35 PM #2
WHere the data types for all except id should match those of the existing table.Code:CREATE TABLE t1 ( id INT AUTO_INCREMENT PRIMARY KEY, title VARCHAR(xxx), http VARCHAR(xxx), recordno INT );
Done.Code:INSERT INTO t1 (id, title, http, recordid ) SELECT NULL, title, http, recordid FROM t2;
Now. How do you know *WHICH* records in t1 match up with which records in t2??????
Is it based on recordid? Or what?
I'm not sure this is the best plan going forward. But you asked.