suicide
Sep 10 2004, 03:54 PM
I have a database that will contain 43 tables (among others). For these particular tables, they will each contain the same type of information, each representing a particular week in the NASCAR season. I used the following script to create one table: DROP TABLE IF EXISTS gulfOwnerDriversWeek1; CREATE TABLE gulfOwnerDriversWeek1 ( ownerIndex int primary key, driverIndex1 int, driverIndex2 int, driverIndex3 int, driverIndex4 int ); This table represents a draft sheet for one particular week (Week 1) for a particular team. My first question is, should try to put all weeks (43 of them) into one database, or should I keep each week in its own table (seems to be the smartest method). The only way I know to create a table right now is either through the mysql command line or a simple script. To create every table I need for my league in this manner would be very difficult. Is there an easy way to create 43 identical tables where the only discrepency between the table names would be the number on the end: gulfOwnerDriversWeek'X'? I have lots of tables like this for stats & what not and can't bring myself to create every one separetly at the command line. Thanks.
Reply
r3d
Sep 10 2004, 09:16 PM
use looping w/ php CODE $starting_count = ???; $howmany_loop = ???; $key = "ownerIndex int primary key, driverIndex1 int, driverIndex2 int, driverIndex3 int, driverIndex4 int";
for($var = $starting_count; $var <= $howmany_loop; $var++) { mysql_query("CREATE TABLE gulfOwnerDriversWeek".$var."(".$key.")"); }
Reply
daf
Sep 12 2004, 03:50 PM
Another approach to this problem is to "merge" week info into your drivers table, instead of spreading it all over 43 tables, requiring in this way a script language to manage it on an higher abstraction level. If you add and ID_WEEK column to gulfOwnerDrivers table, setting ID_WEEK from 1 to 43 for every set of drivers per week, you'll be able to store all your data in one table. All queries concerning this table will be constrained by a WHERE ID_WEEK = <week> clausole in order to select every time only one particular week results. prototype of query for gulfOwnerDrivers: CODE SELECT ownerIndex, driverIndex1 int, driverIndex2 int, driverIndex3 int, driverIndex4 int FROM gulfOwnerDrivers WHERE ID_WEEK = <week>
<week> is an alias for a certain number of week.
Reply
Similar Topics
Keywords : generating, tables
- Mysql Multiple Tables
(1)
Mysql Problem
Linking tables (1) Hello guys, I'm making a PHP/MySQL site for a friend of mine who plays an online game where you
can create towns, add buildings to them and upgrade them to a newer level. I've offered to make
him a small site where he can input his data into a database and keep track of his towns, buildings
and levels. I'll show you my database design and then explain what i want to do. Table: towns
field 1: TownID (primary key, auto-increment) field 2: TownName field 3: TownType field 4: Town
Description Table: buildings field 1: BuildingID (primary key, auto-incremen....
Script Tables On Sql Server Compact
(0) So I have an application that's using SQL Server Compact Edition 2005. I need to export the
table schema to a file of SQL statements, containing only the schema...no data, no rows, just the
tables, indexes, and constraints. Now, when using SQL 2000/2005 I just use the script table as...
feature to do exactly this, but because SQL server Compact Edition doesn't have the support for
it, I can't do this. The tables in SQL Server Compact *do* have the information_schema views
though, so I was wondering if anyone knows of any tools that can read these views and....
(help With Sql And Php)retrive Datas From Realted Tables And Display Them!
Please help me to diplay datas by combining 3 tables! (4) Hi all.. Please help me to write the SQL Query for the following requirement! Im having 3 MySQL
tables Sales_users Sales_products Sales_details 1st Table (Sales_users) contains unique userID
and username for the users! 2nd Table (Sales_products) Contains unique Product ID, product Name and
Product Description! 3rd Table (Sales_details) contacins unique Sales ID, Product ID (Foreign Key),
FromUser (Foreign Key) and ToUser (Foreign Key) Sales_users
User_id name 1 Test1 ....
Linking Two Tables
(12) I have two tables in a database. userid and usercredits In userid I have all the fields that
identify the user (name, address etc.) In my usercredits table I have the following fields: IDNUM
ProgramName Camp# CompletionDate Amount DatePmtSent PmtMethod Comments creditID What I would like
to understand about my table structure, is how do I associate my credits tothe correct user. If I
have done this correctly, there is also a field in the first table that is called IDNUM where each
user has a unique number to identify who they are. When someone is logged into the ....
MySQL, Multiple Tables
(24) Ok, I'm coding a project which is a leap than what I'd normally do. Before, I've always
learned ONE table... put EVERYTHING in one database table. I'm making a profile system so there
needs to be at least two tables: 1 for users, 1 for content. My problem is, how do I link the two
together? I could probably figure this out faster if someone explained and posted sample SQL code
that shows how the two are linked together. Thanks!! F....
Updating A Database's Tables
(10) Is there an "easy" way to update a database's tables? Like for instance, I have my own
custom-coded member login system. Whenever I add a new feature that needs a database, I manually
have to download, update and upload the database. Is there an easy way I can do this? THANKS!!! F....
User Priveileges Vs. Tables Vs Rows
which method is best for accounts/logins (1) I want to know which is the most efficient way to create accounts and logins. I have trouble
deciding which is the better of the three: - User Priveileges - TABLES - Rows....
Creating Tables In MySQL On Home Comp
(8) Hi, I've tried seraching for a bit, but I couldn't find an answer to my questions.
Recently I've succesfully installed Apache on my Windows XP Machine, along with PHP and mySQL. I
need a database on my computer for testing purposes. I've enables mySQL in PHP, and both seems
to be working fine. I can connect to the database, but how do I edit the database? E.g., edit rows
or modify columns. I would much rather stay away from using the command-line stuff. I'm looking
for a GUI Query program that I can use, but I have no clue which one to choose. It ....
Recover Tables From A MySQL .frm File
(8) I have a couple of .frm files with no corresponding data or index files. Is it possible to recover
the table structure (field names, types, sizes, rows,col, etc) from these files? The table type is
innodb....
Selection From Multiple Tables
(0) I am in the middle of creating a little forums system, and all so far is going quite well. However I
have come across a small problem; PHP:
--------------------------------------------------------------------------------
$gather_forums_qry = "SELECT a.frm_id, a.frm_name, a.frm_description,
count(distinct(b.fth_id)) ThreadCount, count(distinct(c.fpt_id))
PostCount, a.frm_enabled, IF( IFNULL( MAX(
b.fth_dateposted), 0) > IFNULL( MAX( c.fpt_datepo....
Looking for generating, tables
|
*SIMILAR VIDEOS*
Searching Video's for generating, tables
|
advertisement
|
|