
![]() |
gnarlyhat
Hehe ... Before I can start Project 1.0 I need to
learnhow to use MySQL instead of a file.I will be doing a simple Wordze API script and then store it into MySQL. First I would need to build me a table to store the list. Being a complete noob at this, after reading thru a tutorial ... I figured ... I need to specify the design the database first.I would want to store my keyword lists into separate categories so it's easy to manage them. Say ... MFA keywords, Adult Keywords, etc. In those of course I have my seed keyword and a huge list of keywords ... may reach 20K lines at times and I reckon 100K when I go crazy into typos and shit.Again ... please correct me if you think there's a better way of doing this. I will create a table each for the category. TABLE MFA id INT seed VARCHAR keywords TEXT TABLE ADULT id INT seed VARCHAR keywords TEXT My only worry is ... will the TEXT field be able to hold that much keywords for me. As I mentioned ... somewhere between 20K to 100K lines. TIA ![]() leadegr00t
Hey there!
Not sure you are approaching the subject correctly,. Yes, design the db first (its a 'measure twice cut once' thing ![]() Perhaps a structure like this: id (primary key, auto_increment) keyword category seednum so each keyword would ap pearonce (ignoring a keyword appearing in more than one cat)categories would repeat frequently and seed would be only a few variations across the rows. does that help? (Possibly first post, not sure - hi guys!) DangerMouse
Hi gnarly,
Personally I'm a firm believer in standards driven code and structures, as such I'd suggest reading up on database normalisation before defining your structure - the rules may seem quite complex at first, but they will hep create an efficient model thats flexible and extensible. Similarly the SQL required may at first seem to be more complex, but using a full relational structure will pay dividends when you come to do more complex queries. I would consider a structure like this: <>tbl_category> - id [Autoincrement] - category <>tbl_keyword> - id [Autoincrement] - keyword - daily_searches - other info directly related to keyword <>tjx_category_keyword> - id [Autoincrement] - fk_Category - fk_Keyword Basically this illustrates the many-to-many relationship between keywords and categories, a keyword can be in many categories, and a category can have multiple keywords. The junction table tjx_category_keyword stores this relationship based on the id numbers from the category and keyword tables (foreign keys). Having never created a keyword DB I dont really know whether this serves as the most pragmatic solution for what your trying to achieve, plus it is probably a little too simplistic when you consider the relationship between keywords and keyword phrases but hopefully it stresses the importance of solid relational modelling. Although the SQL to do this will seem like a baptism of fire at first there are tons of good MySQL syntax examples on the web so it shouldnt take too long to pick up. Forgive me if i've miss read this and your previous post (assuming your new to DB design rather than just MySQL). Hope this helps a little. DM nutballs
go with DMs design, if you think you understand the concepts.
what he has outlined is a 'normalized' database design. You store only data in 'datatables' and relationships in 'lookup' or 'reference' tables. You store in each table information only directly related to the subject of that table. Addresses are an example. street,city,state. In and normalized database structure, the belief is that it would be silly to store all 4 of those in 1 table, since many streets exist in the same city. and many cities exist in the same state, resulting in a lot of repetition, such as the same city being repeated over and over. This makes the db unnecessarily bigger. Fully normalize puts each type of data into its own table, and doesnt store the references in that table. So you would have a table for streets, a table for cities, and a table for states. Then you would create all the relationships in a relationship table by referencing the ID columns of each of those tables. Thus, fk_streetID, fk_cityID, fk_stateID. (fk stands for foriegn key, as opposed to PK, which is the primary key of a table like the ID column). So in the lookuptable you would store in each row, lookupID-fk_streetID-fk_cityID-fk_stateID. Personally, i feel this is overnormalized, and I would store the city and state FKids in the street table, but its easier to understand all broken apart. Normalizing does not mean breaking EVERYTHING up though. Username and Password would not make sense to break up, since you could assume everyone will have a different password, and everyone will definitely have a different username. Firstname,lastname, date of birth is the same thing, breaking it up doesnt get you anywhere. keywords and categories, break it up. 1 keyword may have many categories AND 1 category will have many keywords. So normalize. if you dont want to have to deal with JOINs, which is what you would need to do for a normalized database, you can just go flat. keyword-category-whateverelseyouwanttostore. but that results in a lot of redundancy, and bigger problems potentially, later on when you want to add columns. perkiset
leadegr00t
![]() dangermouse ![]() nutballs ![]() and welcome to the Cache leadegr00t! This is really the way of things. You should really stop typing, read this stuff and get into a beginners MySQL book immediately. The small hiccup time in this beginning will pay off BIG BIG time in the very near future. You should listen to these boys, they're all pre-med. /p gnarlyhat
That went a little way over my head. I should have paid a lot more attention in Database class. I really hated that part. Normalization ... didn't realize it would come back haunting me. To make it simple ... let me explain how I was doing it with flat files.
/MFA(category)/bank-loans(seed).txt <- 5000 bank loan keywords /MFA/bad-credit.txt <- 4700 bad credit keywords /Adult/free-porn.txt <- 8000 free porn keywords /Adult/gay-porn.txt <- 5000 gay porn keywords You get my drift. As far as keywords go ... for now I don't see any of them overlapping into another category but I can't say for sure in the future. I might want to categorize them for different affiliates so there is a possibility of them overlapping. I would of course want to do things right but it might really hinder my process as I find that I need to |

Thread Categories

![]() |
![]() |
Best of The Cache Home |
![]() |
![]() |
Search The Cache |
- Ajax
- Apache & mod_rewrite
- BlackHat SEO & Web Stuff
- C/++/#, Pascal etc.
- Database Stuff
- General & Non-Technical Discussion
- General programming, learning to code
- Javascript Discussions & Code
- Linux Related
- Mac, iPhone & OS-X Stuff
- Miscellaneous
- MS Windows Related
- PERL & Python Related
- PHP: Questions & Discussion
- PHP: Techniques, Classes & Examples
- Regular Expressions
- Uncategorized Threads