manhattes Posted October 16, 2015 Share Posted October 16, 2015 I have a table that has a list of names. 1 name per row. I would like to create a table for each name in the table using the name as the table name. i.e. Table of Names jon bob jess cat creates 4 tables with fields (address, Phone, email,note) table jon table bob table jess table cat Is there a fast way to do this? Quote Link to comment https://forums.phpfreaks.com/topic/298645-creating-new-tables/ Share on other sites More sharing options...
Barand Posted October 16, 2015 Share Posted October 16, 2015 I assume you are talking about HTML tables, that would be a ridiculous thing to do with database tables. Quote Link to comment https://forums.phpfreaks.com/topic/298645-creating-new-tables/#findComment-1523466 Share on other sites More sharing options...
manhattes Posted October 16, 2015 Author Share Posted October 16, 2015 I assume you are talking about HTML tables, that would be a ridiculous thing to do with database tables. no i want to create SQL tables. Quote Link to comment https://forums.phpfreaks.com/topic/298645-creating-new-tables/#findComment-1523469 Share on other sites More sharing options...
benanamen Posted October 16, 2015 Share Posted October 16, 2015 NO, NO, NO!! You are forbidden to do that! You need to study database normalization. Quote Link to comment https://forums.phpfreaks.com/topic/298645-creating-new-tables/#findComment-1523470 Share on other sites More sharing options...
manhattes Posted October 16, 2015 Author Share Posted October 16, 2015 NO, NO, NO!! You are forbidden to do that! You need to study database normalization. I need to store historical data why is this such a crazy thing to do in order to save time? Is it bad to have 300 tables? Quote Link to comment https://forums.phpfreaks.com/topic/298645-creating-new-tables/#findComment-1523471 Share on other sites More sharing options...
manhattes Posted October 16, 2015 Author Share Posted October 16, 2015 NO, NO, NO!! You are forbidden to do that! You need to study database normalization. I am creating a time series and need to dump data there. It is normalized in a master database, but i need to analyze before importing it. Quote Link to comment https://forums.phpfreaks.com/topic/298645-creating-new-tables/#findComment-1523473 Share on other sites More sharing options...
benanamen Posted October 16, 2015 Share Posted October 16, 2015 (edited) Perhaps you should detail exactly what you have and exactly what you are trying to accomplish. I for one don't understand. It would greatly help if you posted an SQL dump of your "Normalized Master Database" along with sample data and details of what you want to do with it. "Analyze" doesn't tell us anything, neither does time series. Regardless of what your doing, creating all those tables is just wrong. Doing the wrong thing never saves time. Edited October 16, 2015 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/298645-creating-new-tables/#findComment-1523476 Share on other sites More sharing options...
hansford Posted October 17, 2015 Share Posted October 17, 2015 Depending what "note" holds and it's size you may need to create another table for that one and just just link to it using a foreign key. CREATE TABLE IF NOT EXISTS Person( id int unsigned NOT NULL AUTO_INCREMENT, firstname varchar(150), lastname varchar(250), address varchar(250), phone varchar(100), email varchar(150), note varchar(250), PRIMARY KEY(id)) INSERT INTO Person(firstname,lastname,address,phone,email,note) VALUES('jon','lastname','address','phone','email','note'), ('bob','lastname','address','phone','email','note'), ('jess','lastname','address','phone','email','note'), ('cat','lastname','address','phone','email','note') Quote Link to comment https://forums.phpfreaks.com/topic/298645-creating-new-tables/#findComment-1523510 Share on other sites More sharing options...
benanamen Posted October 17, 2015 Share Posted October 17, 2015 (edited) @hansford, not sure what your post has to do with the limited info the OP provided, but there would need to be four more tables needed for your example for a properly normalized DB. Another one for address, another one phones along with a phones type table, another one email/electronic communications, and another one note, all of which has nothing to do with "Person" data. Person data would be first, middle and last name, sex, birthdate, hair color, eye color, height and weight, ethnicity, active/inactive, marital status (unless you are tracking those over time, then separate tables for those) Edited October 17, 2015 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/298645-creating-new-tables/#findComment-1523511 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.