1. Registered User
Join Date
Nov 2006
Posts
3

## New to Databases. Looking for advice.

Hello! I am new to these forums. I am a computer science student and I am currently taking a course in databases. This is my first foray into a database class, and to say the least of it; I'm struggling a little bit.

I've browsed this forum a little and it seems like everyone is very knowledgeable and friendly. I too hope I can help other members out with questions sometime in the future.

Now, on to the gritty stuff. As mentioned above, I am taking a database class and had a few questions about a query I have made. First, I'll give the description of the database.

This is a library system database.

Library relation contains: key libno, libname, liblocation, librooms.

Author relation contains: key authno, authorname.

Book contains: key bookno, foreign key authno, booktitle, bookpages.

Copy contains: key copyno, foreign keys libno, and bookno, purchasedate.

Patron contains: keypatno, patname, patweight.

Loan contains: key loanno, foreign keys copyno, and patno, loandate, duedate.

Now the question asks. Make a domain relational calculus for this expression. Find names of patrons weighing more than 200 lbs who have used all Seattle libraries.

Here is what I have.
{n|(E p,w) P(p,n,*,w) ^ (w > 200) ^ (A l) (L(l), *, liblocation, *) ^ (liblocation = "Seattle")}, where E = there exists...(backwards E notation) and A= For all...(upside down A notation)

Now I am having trouble with this:
(A l) (L(l), *, liblocation, *) ^ (liblocation = "Seattle")

when I use (A l) I know this l ranges over the whole database and I want to restrict it to just the library relation. I talked this over with my professor and I had the idea of using something like a set difference (i.e A-B, where A = library relation and B = everything else in the database). He said that was not possible with domain relational calculus.

Does anyone know of anyway to restrict the statement above to just include the library relation?
Any help would be greatly appreciated. I've talked with my professor many times about this problem and he doesn't explain it to me clearly enough. Thanks!

2. SQL Consultant
Join Date
Apr 2002
Location
Posts
20,002
domain relational calculus? who in the real world uses that???!!!!

if we were going to answer that question (as if it matters how many 200-pounders visited all libraries), we'd use SQL

3. Registered User
Join Date
Nov 2006
Posts
3
hahahahaha. Ya, SQL we learn next Wednesday. My teacher still says that it still really depends on relational calculus though, so I should still try and get a good understaning of domain relation calculus.

4. Registered User
Join Date
Nov 2006
Posts
3

## sql query help!

Hi guys! I'm new to this forum and SQL and was looking for some help. I start learning about SQL later this week but I've been reading ahead and decided to start some of the questions in the back of the chapter. Here it goes:

This is a library system database.

Library relation contains: key libno, libname, liblocation, librooms.

Author relation contains: key authno, authorname.

Book contains: key bookno, foreign key authno, booktitle, bookpages.

Copy contains: key copyno, foreign keys libno, and bookno, purchasedate.

Patron contains: keypatno, patname, patweight.

Loan contains: key loanno, foreign keys copyno, and patno, loandate, duedate.

Write a SQL query for the following. Find the names of Seattle libraries that serve a patron weighing more than 200 lbs who has read a Tom Clancy Book.

Select L.libname
From Library L, Copy C, Loan U, Patron P, Loan V, Copy D, Book B, Author A
Where L.location = "Seattle" and L.libno = C.libno and C.copyno=U.copyno and U.patno=P.patno and P.patno=V.patno and V.copyno = D.copyno and D.bookno=B.bookno and B.authno=A.autno and P.patweight>200 and A.authorname = "Tom Clancy"

I'm not 100% sure thisi s the right answer. I'm not sure if the P.patweight should be after U.patno=P.patno. Also, I'm still not sure about how U.patno=P.patno and P.patno=V.patno is correct. I was thinking that it may be U.patno=P.patno and P.loanno=V.loanno because we are looking for the people who have read this book.

If this is confusing, I'm sorry for this. Any help would be greatly appreciated. Thanks!1

5. SQL Consultant
Join Date
Apr 2002
Location
Posts
20,002

so which is it, names of patrons weighing more than 200 lbs who have used all Seattle libraries, or names of Seattle libraries that serve a patron weighing more than 200 lbs who has read a Tom Clancy book?

also, would you mind letting us know which book this is?

6. World Class Flame Warrior
Join Date
Jun 2003
Location
Ohio
Posts
12,595
Originally Posted by ryu12341
hahahahaha. Ya, SQL we learn next Wednesday. My teacher still says that it still really depends on relational calculus though, so I should still try and get a good understaning of domain relation calculus.
Your teacher is a teacher, not a doer. Somehow, I've managed to struggle through a professional career as a Senior Database Administrator and Achitect without knowing Domain Relational Calculus. I can only hope my boss never catches on to my functional illiteracy.

7. World Class Flame Warrior
Join Date
Jun 2003
Location
Ohio
Posts
12,595
Want to know how important Domain Relational Calculus is?
Here is it's Wikipedia article:
http://en.wikipedia.org/wiki/Domain_relational_calculus
And here is a wikipedia article about crap:
http://en.wikipedia.org/wiki/Feces
You'll notice, the article about crap is given slightly more attention than the article about Domain Relational Calculus. Perhaps your teacher could contribute something to the article. Perhaps he could contribute to both articles...

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•