Table Structure Advice
I have two tables - Users and Groups. Pretty straightforward layout where the Users table has ID, last_name, first_name, etc... The Groups table is simply ID, name, description, etc... I want to include in my Users table a group_ids field. What makes this complex, is one user could be a member of just one or many groups, so I can't simply say User1 is in Group1. User1 may be in Group2, Group17,etc...
How does one (or how would you) apply this? I've thought about making the group_ids field a 'text' datatype and separating the group ids by comma or space., but for several reasons this doesn't seem to be the right way to do this.
Let me know if I haven't explained this well or if I should give an example of the data for clarification.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Advice On How To Structure Tables
I currently have a dynamic site that displays info about different musicians. My database is currently set up with a table that contains all the infor about each musican such as name, type of music, website address etc. i.e all single bits of information. Now I would like to add a form to allow the musicians to upload one or more mp3 files. It would be fine if it was just one mp3 file as I would simply have a field in the table to store the name of the mp3 file. However I am not sure how to deal with multiple mp3 files. Do I just create say 10 fields in the table for a maximum of 10 mp3 files for each musician? This doesn't seem the mosst sensible idea but I am fairly new to php and mysql so I am not sure what alternatives there are. I would appreciate some advice on this. I was thinking perhaps I could create a separate table to store all the names of all the mp3 files for all musicians but doing this I do not know how I would know which ones are related to each musician. Also related, should I store the mp3 files in separate folders for each musician or just have one mp3 folder on the server and save them all in here?
Table Design Advice
I'm looking for some advice on suitable ways to construct a table or tables to handle the following situation. I have a dynamic and structured content requirement, where the user can define a new type of item with a new/different set of fields. So I have item types: - name, fields items themselves - one or more field+content pairs depending on the information in item-types. That in itself is pretty straight forward, I can store the item details in a single table of item-id, field-id, value triplets. ie. my db could follow the structure shown at the bottom of the post. However, I need to be able to filter for items based on the values of several fields. In order to do that I can join the item table to itself for each field after the first, e.g. SELECT item-id FROM item-details i1, item-details i2, item-details-i3 WHERE i1.item-id = i2.item-id AND i1.item-id=i3.item-id AND i1.field-id=<field1> and i1.value=<expr1> AND i2.field-id=<field2> and i2.value=<expr1> AND i3.field-id=<field3> AND i3.value=<expr3>; If the item needs to be selected on five fields then there would need to be four joins. Seven ... six, etc, etc. Also, I would like to be able to search the field values without reference to the fields themselves. e.g. Search for all items with a value containing "red". Is this the best way to handle the problem? Is there another table design that would work better? e.g. for each item-type, use the field information to create a table specific to that item-type with columns for each of the fields. Possible structure ============================= item-type - type-id - type-name fields - field-id - field-name - other field data (description, validation, etc) item-fields - type-id - field-id items - item-id - type-id item-details - item-id - field-id - value
Advice On Table Setup To Maximize Efficiency
My table set is is garbage .. I knew this when I created the table a couple of years ago. Now that I have tonnes of data in it the queries are taking forever. So it's about time I constructed a more efficient table. I am turning to this forum for some advice. My table stores RSS feed content in it -- every 15 minutes a cron job INSERTs data from 300+ feeds and dumps it into the table. The table structure consists of: id dateUnix headline - headline of the article permalink - URL to the article body - TEXT type - body of the article author - person who wrote the article authorURL - URL to the person's website favico sitetype - I categorize the types of sites (0 = news media, 1 = blogs, 2= videos, 3= podcasts) vote - users vote on stories verified - 1 = verified, 0 = censored/banned story newsCat - 20 different categories newsSubcat - 50 different subcategories I think the best way to make this table more efficient would be to break it up into 3-4 different tables using the id as the key. ps: my cron job checks for duplicate entries and does not insert duplicates -- so duplicate stories are not entered
Table Optimizing For Big Table. Need Advice.
I need a little help to optimize requests on a table, and I have no idea how to do it (I optimized already a lot other table, but this one is a pain). My table looks like : CREATE TABLE comments ( id int(11) NOT NULL auto_increment, subject varchar(80) NOT NULL default '', timestamp timestamp(14) NOT NULL, user_id int(6) NOT NULL default '1', com_parent int(11) NOT NULL default '0', res_type int(5) NOT NULL default '1', PRIMARY KEY (id), KEY id (id), KEY news_id.........
Table Structure
I see some people like to create different columns for NAME and LAST NAME and some just use NAME as a single column... What are the pros and cons for this two aproaches... which is better?
Table Structure
I have a Users table and a Friends table. The user's table will contain a list of all the users, and the Friends table will contain a list of userIDs that are friends. Users Table: UserID, UserName Friends Table: UserID1, UserID2 Now, my problem is that if Bill and Steve are friends, then I would just have 1 record in the Friends table with their 2 IDs. But then how would I get a list of all of Bill's friends? Or Steve's friends? Bill's ID could either be in the ID1 column or the ID2 column. Is this the right way to design these tables, or is there a better way that can be more easily queried?
Best Way To Structure A Table?
I am creating a user name system in which each user is assigned 100 different types of permissions. Is it better to create a table with one row for each user and 101 columns (1 for userid and 100 for permission values) or 3 columns (1 for userid, 1 for permission id, one for permission value) and then 100 rows for each user or something else?
Table Structure
I am really new to SQL, the question may seem silly. I have three tables with auroincrement numeric ids as primary keys. Tables: 1. Projects (id and details of project) 2. Profiles (id and details of profiles) 3. Tags (id and details of tags) I have created fourth table to store the content id and tag id. 4. Content_tag (content_id, tag_id) (the content_id could be the id of either a project or profile) e.g. The tag house could be used for either project or profile. Question: How can I differentiate (efficiently) which content table the content_id refers to?
Structure Table
how I could structure a table in a situation that has a variable amount of terms. For example, I am using php together with mysql, I want to have a site that can store people's favourite sites. Person A may have one favourite site Person B may have 101 favourite sites How do I structure it? Surely it doesn't mean that Person B would require 101 columns and have 1 website in each column.
Table Structure
I want to display the table structure, what is the statement ?
Table Structure
I have backed(backup.sql) up one Mysql database which contains 10 = tables using mysqldump. Now I want to read just one table structure and it's data from = backup.sql to another database. How do i achieve it. I have tried "mysql databasename < backup.sql" but it will populate the = databasename with all the 10 tables present in backup.sql which i don = want.=20
Table Structure
I am looking for a way to get the table structure from within my schema without using the INFORMATION_SCHEMA (due to suspected security risks and user access). I require the table column names, data types, default values etc from the table structure to basically recreate the table create statement for use in a down sync java app.This would imply that I also need to find the indexes on these tables and the details of these indexes.
Table Structure
I'm building a classified ad and I need to include a field for the price. what's the best "type?" I wont be doing any adding or anything, just to display it correctly.
Table Structure
Trying to assign a unique ID number that auto increments with every new entry. I know this is probably something basic, but with what I have, it crashes MySQL: Current structure: Code: event_id INT(10) NOT NULL AUTO_INCREMENT assigned as Primary Key.
Table Structure
If I have already have a table, I want to know the sql used to create that table, how can I find that out?
Table Structure
I've created a page based on the adjacency model with the following table structure : CODECREATE TABLE def_pages ( file_ID bigint(20) NOT NULL auto_increment, file_parent_ID bigint(20) NOT NULL default '0', file_lang tinytext NOT NULL, file_name tinytext NOT NULL, file_path text NOT NULL, file_status set('show','hide') NOT NULL default 'hide', UNIQUE KEY file_ID (file_ID) ) TYPE=MyISAM;
Table Structure
can someone tell me if there is anything wrong with this table structure and get back with it corrected please? When i try to run the query on my database to make this table. CREATE TABLE users ( id int(11) NOT NULL auto_increment, username varchar(22) NOT NULL default '', password varchar(32) NOT NULL default '', email_address varchar(155) NOT NULL default '', nickname varchar(255) NOT NULL default '', user_level enum('0','1','2','3','4',5') NOT NULL default '0', forum_posts int(11) NOT NULL default '0', profile text NOT NULL, siggy varchar(255) NOT NULL default '', last_post varchar(155) NOT NULL default '0', last_login varchar(12) NOT NULL default '0', style varchar(55) NOT NULL default '0', PRIMARY KEY (id) ) TYPE=MyISAM;
Table Structure
Is there an easy way to compare the structures of two tables and update the structure of one table based on the differences found? I imagine this might work by exporting the structure (not the data) from two tables to SQL files, then compare the two of them to produce a third SQL file with only the differences. I need something like this because I'm running the same database on a number of different sites, and don't want to have to manually update each DB everytime I make a change. Or perhaps someone could offer a procedure I could follow to make updating DB's with new structures less involved? Something that makes it easy for me to keep track of changes I've made.
Structure For A Table
I need to make a new database, and im not sure as to the best way to structure it. Basically, its a database to hold statistics about units in a game. Each unit has a variety of stats defined, and i need to store all of them in the database. The problem is, there is no defined list of stats, new ones are constantly being added (the game is still in beta). So i cant have a table with a column dedicated to each stat. Well, I could if I added a new column every time a new stat was encountered, but that doesnt sound like the best option. I could make a seperate table, that has columns like this: unitId, stat, value but that would quickly grow huge and probably be quite slow, as well as having full text searchs for the stat name. I could abstract it more and have a table for stat names and link it in via id's, but still it would be huge.
Database Table Structure Help
I am not sure how I need to design the following tables. If someone would provide me with a little bit of guidance I would appreciate it. Here is how I see it now: Host -id -name Guest -id -host_id(which is just the id from the host table) -name -email Sizes -id -guest_id(which is just the id from guest table) -sex -small -med -large -xlarge -xxlarge -requests I believe with the above structure I could have a user select a host, fill in their name, email and sizes and submit. Then using an insert (or update, as needed) statement I would insert the host_id, name and email in the guests table and a second insert would insert the size information. I think it looks right but I am not sure,
Introducing A Third Table - New Structure?
I currently have two tables which takes care of multiple galleries, but I've got to the point where i need to restructure and introduce a third table (i think)? What I have already: gallery venue date(primary) photos photo_id(primary) date(foreign) views caption Why do i need the third table? Because all my photos are pointing to 'date' which is my primary key in my 'gallery' table, but I now have photos from different venues on the same date? So what I need is a new way setting this up, because i can no longer have date as the primary? I might also introduce 'event' because i have event@venue, which will repeat some weeks All the new columns: venue event date photo_id date views caption
Viewing Table Structure
How do I view constraints on a table? I can see the table indexes by using "SHOW INDEX FROM mytable;" but this doesn't seem to list any constraints.
Table Structure Question
presently I have two tables (tbl_Groups and tbl_Premises), which I then use to build a third, many-to-many table called m2m_Groups_and_Premises. (Trying to make it easier to poppulate the m2m table). I shall be using the ONUPDATE CASCADE function and so this current table structure may cause me problems as follow: - If I have an entry in tbl_Premises for 'The Best Hotel' and in fact, there are two hotels in different parts of the country with the same name, then wouldn't I have a problem keeping the table m2m_Groups_and_Premises accurate? For example, if one of those hotels were to change its name to 'The Even Better Hotel' my many-to-many table would change the records for both hotels where they relied on the FK of the Premises name. My question is; should I forget the tbl_businessGroups and the tbl_Premises and simply use my script to INSERT to the table m2m_Groups_and_Premises? Maybe there is better - more obvious solution? maybe it would be easier to show you guys the table layouts? tbl_Groups |Group_ID|Group_Name| tbl_Premises |Premises_ID|Premises_Name| m2m_Groups_and_Premises |Unique_ID|Group_ID|Premises_ID|
GOOD TABLE STRUCTURE?
I am redesigning some of the larger tables in my "mysql" database, I want to create a new table with somewhere between 25-30 columns and 1000's of rows. This will be getting queryed alot and query caching is not an option how will this effect the response time of my application and is it better to have more rows or more columns in a table structure as I could redesign either way??
How To Export Db Or Table Structure?
We have a very large MySQL database, and the designer of the database no longer works for us. I need to re-create the same table structure, but without the content, on a separate machine. I know I can do a show tables on the existing db, and also a describe on those tables, so I know what the table structure looks like. I am trying to avoid having to re-type the create table statements for each table. Is there some kind of export command that will export that info to a file without the contents of the tables themselves? The current MySQL server version is 3.23.2-alpha-log. It is running on SunOS 5.6 (i386). If it matters, the new box will be a dual proc linux server, probably running RedHat 6.x or 7.x. We want to start with an empty database on that box.
Table Structure Question
I will have three tables as listed below. I ask for your help on how to relate each of them. I think it may be ok to do it with a many to many table with three fields but I need advice on it from you, more experienced, people. tbl_make | MakeID | Make of car| tbl_model | ModelID | Model Name| tbl_colour | ColourID | Colour Name | I am trying to populate a triple combo though its not absolutely necessary that I do it that way. The key point is that I need to relate tbl_2 with tbl_1 as well as with tbl_3. The makes and models seem straightforward (by using a many-to-many table), because no two makes have the same model name. But, the colours are not so consistent across models and makes because 'mars red' could be used on more than one model and more than one make. Code:
Suggestion For Table Structure
I have 4 products, they can match eachother. A ring can match a bracelet, a bracelet can match a neckless and a neckless can match an earring and so on. I thought I could create tables for each product and then have a table called "match" which has the products primary keys (name) as foregin keys.
Oscom Table Structure
are there any of you guys really familar with the mysql table structure of oscommerce and in particular the search queries?
Database/Table Structure
So I have a database of attorneys. All their basic info is in there, minus the areas they practice because we were waiting on them to get that to us. Now we've got it and I'm unsure how to proceed... I initally thought that nothing would need to be changed in attorney database, and I just needed to add a new table 'practice areas' with the following structure (or something like it: Table-practiceareas Fields=practiceareaname, attorneyname And then because 1 attorney could have multiple practice areas this would work fine...but each practice area could also have multiple attorneys obviously so now I'm stuck and don't know which way to proceed Any advice?
Extracting Table Structure
I currently have a complete MySQL dump for all the tables and data in a database. I'm trying to port it to a different database structure (still MySQL, but different tables, names for columns etc.) so at the moment I'm only interested in the table structure definitions (i.e. CREATE TABLE (....)). Usually I'd just find them all and copy/paste them from the complete dump, but this DB is over 300Mb so that's not really a feasible option. What I ideally want to do is run a simple script (under Linux, maybe in Perl) that will take all the table structure from the existing file and dump it to standard output, so I can redirect it to another file to read from. Does anyone have any idea how to go about this?
Msql Table Structure
I'm planning(and just started) to set up a webshop. To use this webshop everyone has to register themself first with personal information, like address, where they live, phone number, birthdate, username, password, email etc. Also I'd like to store some information on what they have bought, referance number of products they have bought, personal statistics and so forth. I'm all new to mysql, so I'm sorry if this may sound like a stupid question. How should the table be set up? Is all this info I mentioned above too many cells for one mysql table? Should I use many tables or would it work good with just one? If I should have many tables, how do I interconnect with them? like if I had one table for logon info, and another table for products/shoppingcart, and another for personal information.
Search Table Structure Optimization
I am trying to design a database for a search engine so that the structure of my tables is fitting for a high density of queries/hour. Originally, my 'search database' was a single table, with joins from other tables f necessary. I then used mysql 'like' to fetch data for search. No caching, so very rudimentary, I know. (Don't worry about having to port data over. I'm starting over with a brand new project knowing this isn't the best solution, and trying one you propose!) I would like to know how I should set up the tables and columns I should add to enable caching. Or, any other solutions to the problem of designing a database for efficient search! Examples of existing search engine database structures would also be appreciated. How is Google's database designed?
Forum Related Table Structure
I didn't know whether to post this in the php forum or mysql--we'll try this one: Suppose that I have a mysql-php based forum running. Users table (simplified) looks like: Users ------------ user_id (int, primary_key) username (varchar(30)) password (varchar(30)) read_post_ids (text) Currently, 'read_post_ids' is a comma-separated list of all the post ids that a user has clicked on, which are marked as such. Currently a php script is resposible for reading the list into an array, looping through to find values if needed, and on a write back to the db it takes the array and turns it back into a CSV string. Problem: The table isn't even in 1NF because of this field, and extra processing is going on. As an alternative, I have considered dropping 'read_post_ids' from this table, and starting a new table: Read_Post_Ids ------------- id read_post_id user_id This normals the tables and makes queries easier, but I worry about storage. Let's say I have 10,000 forum users, that on average read 20 posts per day. that is 200,000 table rows per day. In a year, I have 71,000,000 rows. If I index the fields (as I probably should for speed), the rows take up even more room. If I decide to only allow a user a maximum of 300 stored 'read posts' (for example), then I probably have to add a timestamp field so I can delete the older ids, which takes up even more space. So is there a preferred method here? I would prefer that the tables be normaled, but I worry about the table growing out of hand in terms of size, and at some point becoming slow.
Just Want To Confirm If Table Structure Is Acceptable
Basically, I am going to be tracking traffic from 3 major search engines and traffic from no search engines. I then want to use my admin panel to view, through an html table I generate on the fly, # of visits by date. So my idea was to have the following structure ID | Date (using date) | IP | Google | Msn | Yahoo | None The idea is with every insert I can put a 'yes' or Ƈ' under the appropriate search engine based on traffic. Is this an acceptable way to build the table and hold millions of records?
Table Structure And Query Efficiency
I've been working on a database which basically incorporates 3 tables to describe say a widget which is either sold or leased. I have the Widget table which stores the information related to the widget itself. I then have a WidgetSale table which stores only information related to the sale of the widget (advertised price, headline, copy, date of sale etc) if it is currently for sale. Finally I have the WidgetLease table which stores only information on the lease of the widget (cost of lease, headline, copy, when current lease is up, etc) if it is available for lease/loan. A widget may be available for sale and for lease at the same time, in which case it will have entries in all 3 tables. When it comes to searching, the searcher may want to include both widgets available for sale and for lease - as such the one widget should be returned twice - once with the details for sale and once with the details for lease. The results are sorted as well so the two entries may appear in well apart from each other in the result set. This was the main reason behind separating the tables in the first place. So basically I create a union of two SQL queries - one which pulls the same details and one which pulls the lease details. Because the fields in both queries need to match I select the common fields from the Widget table first and then for the sale table I select the appropriate sale fields, then nulls for each field which will come from the lease table. In the lease query I do the reverse so effectively I end up with .....
Detecting Corrupt Table Structure?
I think I may have a corrupt table. Problem: An INSERT leaves 3 fields (City,State,Country) blank 30% of the time. I added 3 additional columns: myCity, MyState, myCountry to the end of the table and modified the INSERT to put the same information into these fields and they work perfectly, whereas the prior fields are still occasionally blank. I am suspecting a corrupt table structure. MySQL Administrator reports all OK, however. Environment: Windows Server 2003, MySQL 4.1.9, MyODBC 3.51.10 (not 10-2). Table created originally from Access database and conveted to MySQL MyISAM with "Access2MySQL Sync" product from DMSoft.
Setup Messaging Table Structure
My goal is to make an efficient way to send and store messages for users of my web site. I want the basic functionality of users sending messages (subject,body,date...) to one or more other users. And i also want the option to reply or reply to all. This part seems somewhat easy, but then i want any replies to be part of the same thread so i can show message reply histories.
Indexing And Table Structure Practices
Im using mysql 4.0.23 (win32) Show create: CREATE TABLE `dbcurrent` ( `Filespec` varchar(254) NOT NULL default '', `ID` int(11) unsigned NOT NULL auto_increment, `InUse` int(11) default NULL, PRIMARY KEY (`Filespec`), UNIQUE KEY `IDX_ID` (`ID`), UNIQUE KEY `IDX_INUSE` (`InUse`,`Filespec`,`ID`) ) TYPE=MyISAM MAX_ROWS=100000000; Query : Select Filespec from dbCurrent where inUse is null order by id desc limit 1 Database size : 6,406,347 Is there a better way to index this table so the Query doesnt take forever (this query takes about 30-45 seconds to execute) or a better way to word my query??? Essentially I want the newest record in dbCurrent (by natural ID) thats not marked InUse=1....
Database Structure For League Table
I'm about to try and create a league table with php/MySQL to track games and statistics for an online poker group. Obviously, the most important thing to think about is the structure of the database, but I can't seem to find the best way to do this and was hoping someone could help provide a few ideas on how to keep it clean. At the end of the day I should show a leaderboard, but also be able to display the results of past games - and this is what I am having trouble with when thinking about the structure. I was thinking of a 'games' table to show: Tournament ID. Number of players. Date of game. Start time. End time. This information would then be put into the 'games' table and another form would be produced using the 'number of players' figure to specify the number of input boxes, thus, if there were 7 players we would have 7 boxes. Code:
Export Table Structure And Data
I want to export the Mysql Database to a textfile in SQL. I know there is a way/tool to do this, but I can't get it in control center..
Data Structure Vs Table Loading
I have just started designing database driven websites with MySQL and I would like to know if there is likely to be any performance issues if lots of pages share records from a single table. I want to design a simple website where the contents are derived from two tables "PageDetails" and "contentDetails". The page details will contain all page related info that occurs only once (titles, meta tags etc) and the contents page will contain all the repeating "block" on each page. I am used to designing relational databses for use on a LAN. when I do this I always aim to normalise the design as much as possible for ease of data entry and design maintenance. When I design on a LAN I have a good idea how many concurrent users there are likely to be and how loaded my database tables will be. My concern is, if I use this approach online, the resources of one table will be shared by all pages and all users and I have no idea how many concurrent users there will be on this site but it could be potentially 200. Will there be a noticable performance degredation? The alternative would be to create a pair of tables per page. This would mean any one table would have much less loading, but it would be a maintenance nightmare.
Table Structure For A Product Database
I'm working on a website for my business and have a few questions about how best to design the MySQL database. First of all we have products (art prints) that have lots of options, and the user has to be able to select which one he wants for the particular print. So we'll have one basic art print but it can have up to 21 permutations (example: blue mat gold frame, red mat gold frame, green mat gold frame, etc.). The other thing is that each item may have different quantities and different values of permutations. Basically, some of the items would have the same permutations but other wouldn’t follow any pattern at all. We have less than 150 prints but with the different permutations we have somewhere around 2500 different items. I would like to have just the prints be items instead of having 2500 rows in the product’s table. My question is: how would I best store these values (permutations) in a table so they could relate back to the products table? I would like to have a page where I could select an item, and be able to have it load, from the database, the options for that print in a select box. So I would have one php script that could view any item.
Altering Table Structure In Live Database?
I want to add a field to a table in a database that is live and being accessed from the web. I'm using phpMyAdmin and when I try to add the field I get error #1142 (ER_TABLEACCESS_DENIED_ERROR) "ALTER command denied to user 'xxx' for table 'yyy'" I'm a newbie to MySQL but I guess that's a reasonable error as there are probably open connections. If that is the reason, is there a way I can force all connections to close and not reopen while I make the alteration to the table structure? It won't matter in this case that users will experience access problems while this is taking place (all access is read-only too.) If possible I want to do this without stopping the MySQL server - it is a shared resource AFAIK and the host is in the US (I'm in the UK) so easiest to coordinate if I can do it all from here if possible.
Reading Table Structure And Data From Sql File.
I have backed(backup.sql) up one Mysql database which contains 10 = tables using mysqldump. Now I want to read just one table structure and it's data from = backup.sql to another database. How do i achieve it. I have tried "mysql databasename < backup.sql" but it will populate the = databasename with all the 10 tables present in backup.sql which i don = want.=20
Table Structure For Storing Information In Different Languages
I will develope an application that have data dictionaries translated to some languages. Example of a non-localized table "Thing": thing_id, code, hidden, shortname, longname Target: shortname and longname must be represented in many languages My variants of the solution: Model variant 1 (one table with many columns): "Thing" table: thing_id, code, hidden, shortname_en, longname_en, shortname_de, longname_de, shortname_ru, longname_ru Model variant 2 (two tables with default language in the parent table): "Thing" table in english: thing_id, code, hidden, shortname, longname "Thing_Loca" tabl: thing_id, locale, shortname, longname Model variant 3 (two tables with language data in the child table): "Thing" table: thing_id, code, hidden "Thing_Loca" tabl: thing_id, locale, shortname, longname My questions: 1) Do you know about any other models? 2) Which model would you prefer? 3) Do you konw any internet resources about this problem?
Keeping Track Of Post Views Every Day (Table Structure)
I was thinking of having a table to keep track of post count every day. For example, i have the following table structure: CREATE TABLE `wp_views` ( `post_id` bigint(20) NOT NULL, `year` tinyint(4) NOT NULL, `month` tinyint(2) NOT NULL, `month_hits` int(7) NOT NULL default Ɔ', `day_1` int(6) NOT NULL default Ɔ', `day_2` int(6) NOT NULL default Ɔ', `day_3` int(6) NOT NULL default Ɔ', `day_4` int(6) NOT NULL default Ɔ', `day_5` int(6) NOT NULL default Ɔ', `day_6` int(6) NOT NULL default Ɔ', `day_7` int(6) NOT NULL default Ɔ', `day_8` int(6) NOT NULL default Ɔ', `day_9` int(6) NOT NULL default Ɔ', `day_10` int(6) NOT NULL default Ɔ', `day_11` int(6) NOT NULL default Ɔ', `day_12` int(6) NOT NULL default Ɔ', `day_13` int(6) NOT NULL default Ɔ', `day_14` int(6) NOT NULL default Ɔ', `day_15` int(6) NOT NULL default Ɔ', `day_16` int(6) NOT NULL default Ɔ', `day_17` int(6) NOT NULL default Ɔ', `day_18` int(6) NOT NULL default Ɔ', `day_19` int(6) NOT NULL default Ɔ', `day_20` int(6) NOT NULL default Ɔ', `day_21` int(6) NOT NULL default Ɔ', `day_22` int(6) NOT NULL default Ɔ', `day_23` int(6) NOT NULL default Ɔ', `day_24` int(6) NOT NULL default Ɔ', `day_25` int(6) NOT NULL default Ɔ', `day_26` int(6) NOT NULL default Ɔ', `day_27` int(6) NOT NULL default Ɔ', `day_28` int(6) NOT NULL default Ɔ', `day_29` int(6) NOT NULL default Ɔ', `day_30` int(6) NOT NULL default Ɔ', `day_31` int(6) NOT NULL default Ɔ', UNIQUE KEY `post_id` (`post_id`), UNIQUE KEY `year` (`year`), UNIQUE KEY `month` (`month`) ) Let say, today is the 20th July 2007, so my insert query will be like INSERT INTO wp_views (post_id, year, month, month_hits) VALUES (1, 2007, 7, 1) ON DUPLICATE KEY UPDATE month_hits += 1, day_20 +=1; Is my table structure alright? or is there a more efficient way of doing this?
|