Avatar billede 3z Nybegynder
02. april 2005 - 13:53 Der er 48 kommentarer og
1 løsning

Access kapacitet

Hej,

Jeg er ved at opbygge en Access database til brug for et online ASP system, men er kommet i tvivl om hvordan jeg opbygger den smartest.

Der skal være måske 3-400 forretninger i databasen, som hver især måske har 60-70 varer.

Hvordan opbygger jeg dette smartest/lettest når hver forretning skal have en varetekst og pris for hver af de 70 varer og når de forskellige forretninger ikke har samme varer ? Dvs. der kan ialt måske godt være 1000 forskellige varer med forskellige tekster og priser...

Bør jeg lave en tabel for hver forretning (kan man have 400 tabeller i een Access database og er det smart) eller er der en anden måde som er bedre ?

Håber på snarlig hjælp, for jeg er sgu i tvivl om hvordan jeg laver det bedst ?

Der gives 200 point for hjælp til ovenstående, men er der en skarp ASP/Access programmør som har lyst til at tjene 1000 kr. på lidt programmering og optimering, så sig til !
Avatar billede kalp Novice
02. april 2005 - 14:10 #1
Du kan sagtens have 400 rækker i access.. mener der er en DB størrelses begrænsning på 2-3GB..

Hvad med at have virksomhederne i en database og produkterne i en anden database?
Avatar billede terry Ekspert
02. april 2005 - 14:10 #2
You need ONE table for the "forretninger" and another for "varer"

The varer table will have a field contining a relationship to forretninger so that each forettning has its own varer
Avatar billede terry Ekspert
02. april 2005 - 14:11 #3
contining = containing
Avatar billede terry Ekspert
02. april 2005 - 14:11 #4
no need for one table for each forretning!
Avatar billede kalp Novice
02. april 2005 - 14:26 #5
3z

min ide med at dele det op i to gange database er så du har dobbelt så meget plads
og det er jo det samme.. en relation fra den ene til den anden.
Avatar billede terry Ekspert
02. april 2005 - 14:46 #6
One database with 400 "forretninger" and 1000 "varer" should be NO PROBLEM at all. Access is limited to 2GB for a single database but with these numbers I cant see any problem. I have often had tabases with 500,000 records (500 thousand)
Avatar billede kalp Novice
02. april 2005 - 14:49 #7
terry >> I not saying your wrong about that:)) I did state that the capacity of a access db is around 2-3 GB I just couldn't remember it exactly.

However I the business is expected to grow bigger and (and I talking a lot bigger) then it's good to have med these two seperate databases.

Well atleast that's my opinion:)
Avatar billede terry Ekspert
02. april 2005 - 15:01 #8
hi kalp, we are all allowed to have out own opinions so nothing at all wrong with yours :o)
Avatar billede arne_v Ekspert
02. april 2005 - 15:13 #9
Maximum row size in Access 2000 is 2000 bytes I believe, which mean that
it can contain 1000000+ rows. x1000+ should be more that enough for even
an optmistic business man. And I would expect to see both more complex ASP code
and worse performance with 2 databases. So I would not go that route.

You can have 400 tables in Access (the limit on objects is 32000 I belive). But
it would not be a good design. One table with a field specifying which store
is likely better.

As you describe the problem I think you need 3 tables: store, product and a
storeproduct to map the many-to-many relationship between store and product.

And why am I writing in english ? Terry reads danish fine as dar as I know.
Avatar billede terry Ekspert
02. april 2005 - 15:35 #10
hi Arne, great to see you writing Eglish too, it may encourage others to do the same, then we can make eksperten international :o)

I was also thinking on the lines of a link table (storeproduct) but if each store is to have its own products it shouldnt be necessary.
But then a bit of feedback from 3z might help
Avatar billede arne_v Ekspert
02. april 2005 - 15:43 #11
300-400 stores, 70 products each = 1000 products in total

gives me the idea that it is M:M
Avatar billede terry Ekspert
02. april 2005 - 15:50 #12
tblstore
storeID (primary key)
storeName
..

Product
ProductID
ProductName
StoreID (foreigen key)

but obvioulsy if stores can use the same products then it is a M:M and a third table is required
Avatar billede terry Ekspert
02. april 2005 - 16:08 #13
foreigen = foreign
Avatar billede 3z Nybegynder
02. april 2005 - 17:11 #14
Whats M:M ???

Hmm yes shops in one table and items in another might work, but the difficulty is then that the different shops is likely to have the same items also !

So how would I make the relations so that its possible for the admin to decide which items are used in the different shops and what prices each particular shop has ?
Avatar billede terry Ekspert
02. april 2005 - 17:15 #15
many-to-many
tblstore
storeID (primary key)
storeName
..

Product
ProductID
ProductName

StoresProducts
StoreID (foreigen key)
ProductID (foreign key)
Avatar billede terry Ekspert
02. april 2005 - 17:16 #16
a many to many relationship requires three tables
the middle table just links the other two allowing all storts to use all products
Avatar billede 3z Nybegynder
02. april 2005 - 17:24 #17
So in the third table I would write storeID, productID and then the price ?
So if store 1, 2 and 3 all use item 7, it would look like this:
storeID = 1, productID = 7, price = 23
storeID = 2, productID = 7, price = 25
storeID = 3, productID = 7, price = 20
Avatar billede 3z Nybegynder
02. april 2005 - 17:25 #18
hmm that might work actually - I just need to redo my programming then :)
bugger
Avatar billede terry Ekspert
02. april 2005 - 17:28 #19
Yes, the information which differs, such as the price would be in the third table.
Avatar billede terry Ekspert
02. april 2005 - 17:29 #20
02/04-2005 17:25:56 :o)

You should always design your database BEFORE programming begins!
Avatar billede 3z Nybegynder
02. april 2005 - 17:30 #21
No thats gonna be fucked up coz to lookup a list of products for a particular shop I would need to make multible lookups in the tblstore and tblproduct...

After finding a relation in the StoresProducts table I would need to make a selection in the tblproducts for every product to get the description ! That will give me multiple selections and lookups in tblproducts ???
Avatar billede 3z Nybegynder
02. april 2005 - 17:38 #22
Something like:

SQL = "Select * from StoresProducts where ID = 14"
set rs = Conn.execute(SQL)

Do while not rs.EOF
  SQLp = "Select * from tblProducts where ID = " & rs("ProductID") & ""
  set Prs = conn.execute(SQLp)
  response.write Prs("Productname")
  response.write rs("price")
rs.movenext
loop
Avatar billede terry Ekspert
02. april 2005 - 17:39 #23
with a many to many relationship you can make ONE single SQL to get ALL information for all stores, and if required, for a single store!
Avatar billede 3z Nybegynder
02. april 2005 - 17:40 #24
please help me then :)
Avatar billede terry Ekspert
02. april 2005 - 17:43 #25
SELECT tblStore.StoreID, tblStore.StoreName, tblStoreProduct.ProductID, tblStoreProduct.ProductPrice, tblProducts.ProductName
FROM (tblStore INNER JOIN tblStoreProduct ON tblStore.StoreID = tblStoreProduct.StoreID) INNER JOIN tblProducts ON tblStoreProduct.ProductID = tblProducts.ProductID;
Avatar billede terry Ekspert
02. april 2005 - 17:44 #26
that SQL gives you all information.
and just for storeID = 14

SELECT tblStore.StoreID, tblStore.StoreName, tblStoreProduct.ProductID, tblStoreProduct.ProductPrice, tblProducts.ProductName
FROM (tblStore INNER JOIN tblStoreProduct ON tblStore.StoreID = tblStoreProduct.StoreID) INNER JOIN tblProducts ON tblStoreProduct.ProductID = tblProducts.ProductID
WHERE (((tblStore.StoreID)=14));
Avatar billede 3z Nybegynder
02. april 2005 - 17:48 #27
hehe ok my programming skills are way behind I see... even difficult for me to see exactly whats gonna happen with you SQL
Avatar billede terry Ekspert
02. april 2005 - 17:49 #28
You should try using Access's query designer, this lets you experiment before putting it in code
Avatar billede 3z Nybegynder
02. april 2005 - 17:58 #29
hmm how do I exactly get the output of your SQL... ?

response.write ???
Avatar billede terry Ekspert
02. april 2005 - 18:09 #30
Well I know very little to ASP but it should be the same as before using response.write

I'm off now, guests comming very shortly, will look again later or tomorrow

have a good evening
Avatar billede arne_v Ekspert
02. april 2005 - 20:01 #31
Simple and complex SQL are exactly the same in ASP ADO, so if you could do it
with 2 tables, then you can also do it with 3 tables.
Avatar billede arne_v Ekspert
02. april 2005 - 20:02 #32
You execute the query and get back a record set where you can access
columns in the result by name.
Avatar billede terry Ekspert
03. april 2005 - 10:33 #33
You can also save the SQL as a query in the Access database WITHOUT the WHERE part. Then in your ASP select from the query instead of the table, and now adding the WHERE part

SELECT * FROM MyQuery WHERE StoreID = 14
Avatar billede terry Ekspert
03. april 2005 - 10:33 #34
and as Arne says you now have access to the field names as before.
Avatar billede 3z Nybegynder
03. april 2005 - 12:29 #35
I see that you are linking the tables together but I still can't see how I get the output - this is how I would do but it doesn't work:

SQL = "SELECT tblStore.StoreID, tblStore.StoreName, tblStoreProduct.ProductID, tblStoreProduct.ProductPrice, tblProducts.ProductName FROM (tblStore INNER JOIN tblStoreProduct ON tblStore.StoreID = tblStoreProduct.StoreID) INNER JOIN tblProducts ON tblStoreProduct.ProductID = tblProducts.ProductID WHERE (((tblStore.StoreID)=14))"
set rs = Conn.execute(SQL)

response.write rs("tblStore.StoreID")
Avatar billede terry Ekspert
03. april 2005 - 12:34 #36
as I said I know almost nothing about ASP, but I am sure you need to use onlythe field name NOT the table.

response.write rs("StoreID")
Avatar billede 3z Nybegynder
03. april 2005 - 12:39 #37
but I can't even get the "set rs = Conn.execute(SQL)" to work - keeps giving me an error... maybe I can't use that method along with your advanced SQL...
Avatar billede 3z Nybegynder
03. april 2005 - 12:51 #38
SQL = "SELECT tblStore.ID, tblStore.StoreName, tblStoreProduct.ProductID, tblStoreProduct.Price, tblProduct.ProductName FROM (tblStore INNER JOIN tblStoreProduct ON tblStore.ID = tblStoreProduct.StoreID) INNER JOIN tblProduct ON tblStoreProduct.ProductID = tblProduct.ID WHERE (((tblStore.ID)=1))"
set rs = Conn.execute(SQL)

ERROR:
[Microsoft][ODBC Microsoft Access Driver] Type mismatch in expression.
Avatar billede 3z Nybegynder
03. april 2005 - 13:06 #39
seems like there is an error in the SQL expression...
Avatar billede terry Ekspert
03. april 2005 - 13:15 #40
without seeing the tables/fields you are using I cant comment on the the SQL being correct or not.

ERROR:
Type mismatch! are you sure that ID is a numeric value?

You should try the SQL in Access, then when it works save it as a query (IN ACCESS)
Avatar billede terry Ekspert
03. april 2005 - 13:16 #41
The SQL is not that advanced, ther should be no problem using this in ASP (ADO)!
But if it doesnt work in Access then it will not work in ASP :o)
Avatar billede 3z Nybegynder
03. april 2005 - 13:18 #42
the thing is that I dont know how to make this SQL in Access...
Avatar billede terry Ekspert
03. april 2005 - 13:21 #43
can you send me your database and I will do it for you?

eksperten@NOSPAMsanthell.dk

remove NOSPAM
Avatar billede 3z Nybegynder
03. april 2005 - 13:21 #44
shit sorry - one field was not numeric....
Avatar billede 3z Nybegynder
03. april 2005 - 13:23 #45
hehe seems to be working now - been looking at it for so long and then a simple fuckup is the reason...
Avatar billede terry Ekspert
03. april 2005 - 13:24 #46
the fields you are joining on must be the same and if the fields in the WHERE part are text then you must use

WHERE tblStore.ID = '1'
Avatar billede terry Ekspert
03. april 2005 - 13:30 #47
I'm off out for an hour!
Avatar billede 3z Nybegynder
03. april 2005 - 13:45 #48
thank you for you help !
Avatar billede terry Ekspert
03. april 2005 - 14:33 #49
thanks, great to hear its working
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester