Two more queries

I am teaching a Dreamweaver workshop this evening so I have to head out soon but wanted to post links to two more database queries that I’ve developed.

: Lists the authors and resources
Resource/Author: Lists the resources and authors

I struggled with the author query (even though I had already successfully created the resource query) because I was matching the ids of the author and resource so I wasn’t getting the right author/resource combination.

I’m also doing some behind-the-scenes troubleshooting to make sure that edits and deletes are not just being made in the main tables but also in the lookup tables. Last night, I discovered that, while the keyword edit/delete was working, the author was not so the links were still in the lookup table. I believe everything is working now but it’s just a reminder that even though things appear to working on the surface, the integrity of the database has to be maintained.

All She Wants to Do is Code!

I am coding every chance I get and moving right along on the project (but oh is there PLENTY of work still to do). The basic data entry pages are done. I am going to just create a generic resource entry page that includes all the fields in the resource table. Later I can make specific pages for each type of resource.

Right now I am working on nested queries and starting to try to add in formatting. Here are a few queries of the database:

Quote/Resource Query
: This query shows the quotes first and then the resources. It passes the quote id so you can use the options to edit or delete quotes as well as add notes related to quotes (rather than resources).

Resource/Quote Query: This query shows the resource first and then the quotes. It passes the resource id so you can use the options to edit or delete the Resource as well as add quotes or notes related to the resource (rather than the individual quote).

Show All Notes: You can use this search interface to see notes related to specific resources or keywords. OR if you don’t choose anything, you can see all the notes in the database including those related to resources AND to quotes. You can also edit or delete notes from this screen.

I am currently working on the queries to show all the notes related to a specific quote. It is a two-step process. You start by searching for quotes related to resources and then click the View Notes button. I still need to add the options for editing notes to this page.

And…someone added a resource to my database! I guess I better start thinking about a password protected version to use for myself. Actually, with the Apache server on my laptop, I could use run MY version locally.

More Database News

I have gotten past several hurdles to have at least a skeleton of a functioning database. You can add quotes related to resource and also add notes related to either quotes or resources. I’m also working on the page design and thinking about other things I want to add like a “show quotes” link in the Resource list that shows up when you do a search. And I also need a “show notes” button in the Quotes list that shows up when you search.

There are several pages still to be done: a quotes edit and delete and a notes edit and delete.

Then I need to start working on querying: what results do I want? And what do I want to be able to do with them when I get them (edit, delete, etc.)

I also need to work on the pages for different types of resources. I’ve got all the fields created in my database. I need to add them into the resource data entry pages. So…lots to do but I think I know it’s doable.

Monday Morning Update

Hard to believe it’s been two weeks since I posted anything at all but it’s not for lack of work. I decided I needed some academic work so have been reading about php. I have tinkered with the database, adding fields based on RefWorks. I have also added a page for adding quotes and, hopefully this afternoon, will put one together for adding notes. But I took some time to work with queries and now have two nested queries that use a function to show all the resources related to an author and all the authors related to a resource. Here’s the resource with author query that returns all the authors associated with a book. And here’s the author with resource query that returns authors with all the resource associated with them. I used a query from the Williams and Lane book as a basis for these.

Monday Morning Update

With just a little code review help from my husband, I was able to go to bed last name knowing that my database is working! I was able to use PHP to write to my lookup table and then do simple searches on authors, keywords, and types. I have a long list of things to do:

1. Pull-down menu to choose the type of resource (books, journals, etc.) that brings up a specific data entry page. I built one in html but it didn’t carry the type_id variable to the data entry page so the user had to choose the type twice.
2. Complete the delete resource and edit resource pages in the current version of the database.
3. Diagram the database using fields from RefWorks.
4. Put the database connection script into an include that I can just drop into each page. (This idea came from my husband: I have just been copying and pasting the connection script into new pages but he said using the include would be more secure.)

Then there’s a TON of coding to do!! But at least I feel like I have a proof of concept right now. I am also not ready to wean myself from the book yet. I could probably do a simple php script from scratch but I still need an example. Bu now I have my own. My biggest problems are getting the field and variable names wrong. The process can be frustrating but there is usually some simple change to make the code work. And it’s pretty exciting when it does work!

For now, I have a couple other projects that I have to work on but I’m hoping to find a little time to code sometime today. If I can work in an hour or so a day, I think I’ll remember the process better and be able to chip away at the work.

Getting Closer

So, I have been coding every spare minute although the weather is beautiful so I took some time off yesterday afternoon and this afternoon. But I’m back at it because I feel like I am so close but I need to step back a minute and consider my issues:

I decided to call the project “noter” and have created a main index page here. A user can add an author, a keyword or a resource (for right now books only). And the resource entry form has a pull-down menu for type and checkboxes for authors and keywords. Because I want to design separate entry forms for each type of resource, I started with a page for books. (I spent some time with RefWorks and have a general idea of what fields go with each type. I’ve already got the types from RefWorks in the database and will eventually add the other fields as well.) The type ID works (although it took me awhile to get it to recognize that I had chosen a type).

Here are my two major problems right now:

1. The code that links the resource id with the keyword id is writing correctly to the keywordlkup_r table so that resources are associated with keywords in a many to many relationship. However, when I use the resource search page and search on the keyword, I see ALL the titles in the database.

2. The code that links the resource id with the author id in the authorlkup table is not writing correctly to the table so resources are not being linked with authors. Thus, when I use the resource search page and search on author, I see nothing.

3. The text search doesn’t work either.

I’m a little stumped right now. Somehow, the search isn’t looking the right place it would seem in problem #1. for problem #2 I think it’s an issue of having two chunks of code back to back. The join for the keyword/resource is first so it gets executed but the second one doesn’t. The page does indicate that the resource was added to 0 authors so it recognizes that it isn’t working. Hmmm…And, I suspect when I solve #1, I will also solve #3 and that would be the break through because it would mean that the relations were working.

Some Very Simple Code

I managed to devote more time this afternoon and have not only a database to show for it but two php pages that display information. The first one queries just the resource table for titles. The second one queries both the resource and the author tables to display titles with their authors. It has a problem in that it repeats the listing over and over for the 30 lines allotted.

Despite that, I feel pretty good about my database. Now I really have two things to do: draw a picture of the database and continue learning how to query using php. For the second page referenced above, I let phpMyAdmin write the php code.

At Least Some Success

A fruitful two hour work session! I created tables and learned to do elementary joins. I understand how to make joins between two tables that have a one to one relationship. Now I need to figure out how to query in order to get all the quotes and notes associated with a resource. (And I noticed that phpMyAdmin will even write the php code for you!) I followed Ullman’s directions although I created tables related to my project. Now, I’ve turned to Williams and Lane and later this afternoon (after teaching a class), I plan to settle in and read more about relationship databases. I know, I know: I should have done all that before starting to create tables but I just needed to at least start something even if it has to be changed later. Besides, I have a pretty good diagram of the wikindx database as well as my own work in Access. So, I just created a barebones bibliography skeleton and added notes and quotes tables. I did use RefWorks’ list of types of resources.

SQL Update

Well, I wasted a lot of time last night trying to get logged into mysql on my simplykaren server. Then, I tried creating a database and got a variety of different error messages ranging from incorrect syntax to access denied. So…I’m giving up on the terminal window and working with phpmyadmin to create my databases for now. I am eager to really dig into this project and want to get past the “stalled out” feeling I have had for the past week.