ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old August 24th, 2003, 12:01 PM
seb835 seb835 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: UK, London
Posts: 95 seb835 User rank is Lance Corporal (50 - 100 Reputation Level)seb835 User rank is Lance Corporal (50 - 100 Reputation Level)seb835 User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 29 m 2 sec
Reputation Power: 5
Help with simple database relationships

Hi, I have a small problem with my Access database.

Here is my example:

A table stores a userName and a Password.

Another table stores up to 10 URLs.

How can I make it so that each time a new user signs-up to my site, they get their own 10 spaces to save URLs? Im assuming that I have to create some sort of relationship, rather than create a new table for each users URLs to be saved.

Many thanks for any help offered,
Seb

Reply With Quote
  #2  
Old August 24th, 2003, 02:14 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,717 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 40 m 34 sec
Reputation Power: 688
Just store the username or userid as a foreign key in your url table. Then you can select url from urltable where userid = nnnn

If you need to preset values your signup code could insert the desired 10 blank url records at the initial login, or you could skip that and let the user's urls range from 0 to 10 or more.

You may wish to define a relationship between the two tables, but it's not an absolute requirement.

Reply With Quote
  #3  
Old August 24th, 2003, 02:34 PM
seb835 seb835 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: UK, London
Posts: 95 seb835 User rank is Lance Corporal (50 - 100 Reputation Level)seb835 User rank is Lance Corporal (50 - 100 Reputation Level)seb835 User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 29 m 2 sec
Reputation Power: 5
Thanks Doug im really grateful for your help, but im afraid I have no idea how to define a foreign key in the url table in MS Access...could you please tell me how?

Many thanks!

Reply With Quote
  #4  
Old August 24th, 2003, 02:59 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
give this a shot...
Code:
"CREATE TABLE tablename (
     usrID whatever data type your username is, 
     URLs whatever data type URLSs are,
     etc...........
     PRIMARY KEY (usrID),
     FOREIGN KEY (usrID) REFERENCES otherTableName.(usrID)
)

Reply With Quote
  #5  
Old August 24th, 2003, 03:15 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
of course if your table is loaded with lots of info and you can't recreate just add that extra line in for a contraint, I would assume access can do that but I've never touched an access DB in my life and probably shouldn't be giving advice on it but that's the SQL standard way of doing it and I assume you can do that in access as well, if anyone else can verify?

Reply With Quote
  #6  
Old August 24th, 2003, 04:24 PM
seb835 seb835 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: UK, London
Posts: 95 seb835 User rank is Lance Corporal (50 - 100 Reputation Level)seb835 User rank is Lance Corporal (50 - 100 Reputation Level)seb835 User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 29 m 2 sec
Reputation Power: 5
thanks again for all your help, the last thing i need to know is this, look at the follwing line of code:

SQL_DetailsRetreival = "SELECT urlName, urlAddress FROM tblURL WHERE userID = 1"

At the end is uderID which is set to 1. How can i replace this number 1 with a string which holds a different number?

thanks again!

Reply With Quote
  #7  
Old August 24th, 2003, 04:27 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
it depends:

vbscript:
SQL_DetailsRetreival = "SELECT urlName, urlAddress FROM tblURL WHERE userID = " & string

javascript:
SQL_DetailsRetreival = "SELECT urlName, urlAddress FROM tblURL WHERE userID = " + string

Reply With Quote
  #8  
Old August 24th, 2003, 04:37 PM
seb835 seb835 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: UK, London
Posts: 95 seb835 User rank is Lance Corporal (50 - 100 Reputation Level)seb835 User rank is Lance Corporal (50 - 100 Reputation Level)seb835 User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 29 m 2 sec
Reputation Power: 5
Hi thanks for the reply, this is what I entered:

SQL_DetailsRetreival = "SELECT urlName, urlAddress FROM tblURL WHERE userID =" & sessionID

bear in mind the sessionID variable holds a number (from 1 up to any number).

When I try the page with your example code I get this message:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'userID ='.

/faves.asp, line 23

Reply With Quote
  #9  
Old August 24th, 2003, 04:40 PM
seb835 seb835 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: UK, London
Posts: 95 seb835 User rank is Lance Corporal (50 - 100 Reputation Level)seb835 User rank is Lance Corporal (50 - 100 Reputation Level)seb835 User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 29 m 2 sec
Reputation Power: 5
Sorry false alarm you ARE correct it DOES work! My browser had dropped the session ID for some unknown reason!

Thanks for your help!

Reply With Quote
  #10  
Old August 24th, 2003, 04:41 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
Hmm, i assumed you didn't need ' around the variable since your 1 statement worked, but in anycase try kicking it with this

SQL_DetailsRetreival = "SELECT urlName, urlAddress FROM tblURL WHERE userID ='" & sessionID & "'"

i"m just adding ' around the variable.

also, did you print sessionID? what's it's value?

Reply With Quote
  #11  
Old August 24th, 2003, 04:43 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
ack, you're starting to sound like my boss saying my code doesn't work when it does

Reply With Quote
  #12  
Old August 24th, 2003, 05:36 PM
seb835 seb835 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: UK, London
Posts: 95 seb835 User rank is Lance Corporal (50 - 100 Reputation Level)seb835 User rank is Lance Corporal (50 - 100 Reputation Level)seb835 User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 29 m 2 sec
Reputation Power: 5
hehehe, just one more thing...

Do you know how to do this:

When a frame page loads, (for example the bottom frame) can i make that trigger the top frame page to refresh?

thanks again!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Help with simple database relationships


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |