I'm trying to learn more about db interactions which has me developing a local app to get started. Well, basically, what I've done so far has had some mixed results and I've changed so much stuff I'm not even sure what I've change at this point, lol. I'm not quite sure one of my tables was correct, so I've decided to just start that over. Here's what I want my silly local app to do.
- Store up to 9 specific RSS feeds (I did url/links before but I don't want to get confused by anything I did before so I'm changing it to RSS feeds)
- 1 feed will be populated by default (so every user has that one common feed - which they can change)
- Feeds should be stored in some ordering scheme so they can be retrieved/printed in the same order they were entered in.
There will be an edit screen with 9 text fields, populated by corresponding db entries, so something like:
feed 1: <input type="text" value="http://rss.news.yahoo.com/rss/topstories"> **the default feed for everyone, but they can change it**
feed 2: <input type="text" value="http://content.usatoday.com">
feed 3: <input type="text" value="http://newsrss.bbc.co.uk/rss/newsonl.../world/rss.xml">
feed 4: <input type="text" value="">
feed 5: <input type="text" value="">
feed 6: <input type="text" value="">
feed 7: <input type="text" value="">
feed 8: <input type="text" value="">
feed 9: <input type="text" value="">
<input type="submit" value="update">
I want to be able to edit/add new feeds here and retrieve those feeds in the same order - this was a big source of my confusion in my prior attempt.
There will be an output screen which outputs the feed URLs in the same order.
I have 2 tables, users and now feeds, I believe my users table is fine, it basically stores a little personal information. I think everthing there should be pretty obvious. The 'state' column is going to store a 2-character state abbreviation from a select/dropdown and I've indexed it as I'd like to be able to search for users by state. I'm not having any issues retrieving/editing/updating that data.
CREATE TABLE users (
user_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
first_name VARCHAR(20) NOT NULL,
last_name VARCHAR(40) NOT NULL,
state CHAR(2) NOT NULL,
email VARCHAR(60) NOT NULL,
pass CHAR(32) NOT NULL,
registration_date DATETIME NOT NULL,
PRIMARY KEY(user_id),
UNIQUE (email),
INDEX login (email, pass),
INDEX state (state)
);
Here's my new feeds table
CREATE TABLE feeds (
user_id SMALLINT UNSIGNED NOT NULL,
feed_url VARCHAR(255) NOT NULL DEFAULT 'http://rss.news.yahoo.com/rss/topstories',
feed_id SMALLINT UNSIGNED NOT NULL DEFAULT 1,
PRIMARY KEY(user_id, feed_url)
);
When a user enters a new feed, let's say for feed #2, the value would be inserted into feed_url and feed_id would be inserted with a value of 2. If feed #3 is entered, feed_id would be inserted with a value of 3. That should give me something to ORDER BY to retrieve records in order, right?
The data edit screen should always display the feeds how they were entered.
The data output screen should always display the feeds how they were entered.
So, does this look proper and am I missing some things? My feed_url VARCHAR(255) might not be foolproof but I'm only going to be testing with short urls. It could always be easily bumped up, too.