PowerBASIC Forums
  Programming
  shared database help (Page 1)

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone!
This topic is 2 pages long:   1  2 
next newest topic | next oldest topic
Author Topic:   shared database help
Jazmin Stevens
Member
posted May 25, 2004 10:18 PM     Click Here to See the Profile for Jazmin Stevens     Edit/Delete Message   Reply w/Quote

hello, i am looking for information about databases, i need to know how they work and what i need to do to allow multiple computers modify a database at the same time keeping the information accurate. i am a complete newbie for this matter. please post an example for power basic for DOS, qbasic or any other basic language. please help. thanx.

------------------

IP: Logged

Shawn Anderson
Member
posted May 26, 2004 12:02 AM     Click Here to See the Profile for Shawn Anderson     Edit/Delete Message   Reply w/Quote
Jazmin,
not every database is the same, they all have advantages and
disadvanteges. If you could describe what you're trying to do
in a little more detail, you'd probably some good starting
ideas.

In Basic, the random access database is probably the most used.
Look up "random access files" in the PB help file.
You will need to create routines for adding, editing, deleting,
and indexing your database. This is not a trivial task.
I'm not real familiar with pb/dos but here is some sample
code that should be pretty universal (I just typed this in
from the top of my head so it is untested):


' sample code for name and phone number db

' declare our data type - each record is 30 bytes long
type recType
rName as string * 20
rPhone as string * 10
end type

function pbmain()
' declare some variables
local recVar as recType
local fNum as long
local fName as string
local recs as long

' open the data file
fNum = freefile 'this gives us an available file handle
fName = "data.dat"
open fName for random as #fNum len=sizeof(recVar)

' recs variable tells us how many records in the database
' before we add ours to the end
recs = lof(fNum)/len(recVar)

' populate a record variable with data
recVar.rName = "Mike Tyson"
recVar.rPhone = "3095551212"

' write the data to the database file at the end of the file
put #fNum,recs+1,recVar

' read the record back from the database file
get #fNum, recs+1, recVar

' print the data
print recVar.rName
print recVar.rPhone

' close the database
close #fNum

end function

This example is very basic but maybe will give you an idea of
where to start.

------------------
http://www.nbson.com
CIW, A+

IP: Logged

Jazmin Stevens
Member
posted May 26, 2004 12:51 AM     Click Here to See the Profile for Jazmin Stevens     Edit/Delete Message   Reply w/Quote

hello, thank you very much shawn, but, how can i make a program that can modify the same file from several workstations at the same time? im sorry if i dont describe with detail, but i dont really know what to ask for, i just need a way to make a database program that can add/delete/modify records from several computers at the same time.

------------------

IP: Logged

Brad D Byrne
Member
posted May 26, 2004 01:06 AM     Click Here to See the Profile for Brad D Byrne     Edit/Delete Message   Reply w/Quote
I know very little about this.. but you need to set up a
client/server environment... and "broadcast" to all the neworked
computers when the data changes.. so they know to update..

you will probably want an sql or xml server?? I think?

commented .. just to try to help start topic discusion

------------------
Washington DC Area
Borje's "Poff's" is likely the BEST tool for learning PB.. http://www.tolkenxp.com/pb
And a few PBTool's & Beginner Help:http://sweetheartgames.com/PBTools/JumpStart.html

IP: Logged

Jazmin Stevens
Member
posted May 26, 2004 03:59 AM     Click Here to See the Profile for Jazmin Stevens     Edit/Delete Message   Reply w/Quote

hello brad, how do i do all of that? how do i broadcast?

------------------

IP: Logged

Terry Fritts
Member
posted May 26, 2004 07:15 AM     Click Here to See the Profile for Terry Fritts     Edit/Delete Message   Reply w/Quote
quote:
information about databases

There are many databases that can be used with PB.
Generally these fall into 2 categories: embedded or servers.

Embedded simply means that the database lives with the program
and the program uses it directly. This could be as simple as a
single text file. Candidates you might consider include
Cheetah http://www.planetsquires.com/
Tsunami http://www.trm-ug.com/
Sqlite http://www.sqlite.org/
Powertree http://www.powerbasic.com/products/powertree/
and others (see the PB links page)

These require special code and libraries and the code varies
with the product. The Sqlite database uses a subset of the SQL
syntax. Powertree is not a database per se but a way to use
a file of data and index the file.

Database servers on the other hand are programs which run on a
remote computer and which permit a client program to access data
on the remote computer. Examples include:
Microsoft SQL 2000, SQL 7, and others
MySql http://www.mysql.com/
Oracle
many, many others

These generally are manipulated using ODBC or ADO drives which
require a library for the interface usually provided by
the vendor. A library for your program such as
SQLTools http://www.powerbasic.com/products/sqltools/
and usually data is accessed via SQL (structured query language).

It is also possible to make any embedded database a server by
writing your own server program. A forum contributor has done
this with Tsunami as an example - see http://ttds.greatwebdivide.com/ by Don Dickinson.

quote:
i need to know how they work

That question is too broad to be specific. But generally a
database provides a means to locate, access, and manipulate data.
Usually this is done by creating an index (or several) that
keep track of various portions of the data.

quote:
what i need to do to allow multiple computers modify a database at the same time keeping the information accurate.

That requirement favors a database server. Which database server
depends upon a lot of things. If your users are going to connect
to the database server over the Internet then who will host it and
what do "they" offer being of paramount interest. If the host
provides MySql then your program has to use MySql.

If you have to also provide the host resources then you have more
research and analysis to do depending upon your project requirements.

Best wishes.

IP: Logged

Michael Mattias
Member
posted May 26, 2004 08:00 AM     Click Here to See the Profile for Michael Mattias     Edit/Delete Message   Reply w/Quote
> but you need to set up a client/server environment... and "broadcast" to all the neworked computers when the data changes

Um, no you don't; you 'can' if you want, but you don't 'need to' do so.

For "regular" files the SHARE and LOCK options of the OPEN statment, as well as the LOCK/UNLOCK functions, and the ERR returned when one computer tries to access a file or portion of a file currently in use by another computer provide everything your need.

That said, this is not particularly easy to code.

If you are using a commercial database, there are options available both the DBMS and through SQL to control access. (Usually not necessary, as most operations on a database are "user-count-agnostic").

MCM


IP: Logged

Tom Hanlin
Member
posted May 26, 2004 01:41 PM     Click Here to See the Profile for Tom Hanlin     Edit/Delete Message   Reply w/Quote
Jazmin, please register with your real name, as you agreed during
the registration process.

------------------
Tom Hanlin
PowerBASIC Staff

IP: Logged

Elias Montoya
Member
posted May 26, 2004 04:49 PM     Click Here to See the Profile for Elias Montoya     Edit/Delete Message   Reply w/Quote

Tom she is my girlfriend, she connects from my computer,
i helped her registering from my computer, she just came
back and we tried to reply and we found out that her privileges
where removed.

We had a hard time creating a hotmail account for her and
i dont think its fair that she was blocked, but oh well, Dont
worry, this was a quick question and i doubt she will need to
post anymore.

Elias

------------------
Last night i was decided to retreat, Then i decided not to.

Do you need a grid In your App?.... Try the Egrid32 Demo:
EGRID32 DEMO DOWNLOAD
PRO Version Released!
Egrid32's Page

IP: Logged

Tom Hanlin
Member
posted May 26, 2004 05:25 PM     Click Here to See the Profile for Tom Hanlin     Edit/Delete Message   Reply w/Quote
Please make sure she knows this is a forum for PowerBASIC, not "qbasic or any other basic language".

------------------
Tom Hanlin
PowerBASIC Staff

IP: Logged

Ian Cairns
Member
posted May 26, 2004 07:30 PM     Click Here to See the Profile for Ian Cairns     Edit/Delete Message   Reply w/Quote
Database design in a single-user environment can be tricky enough.
Designing a multi-user database from scratch is likely to be an exercise
in frustration for a "newbie". You can't let multiple users modify the same
record simultaneously. This is why you will need to use file or record
locking. I do "roll-your-own" simple databases. I have only done one in
a multi-user environment. I used a "master" "lock file" that I use to
identify users, files and records that are not permitted to be changed while
someone else is changing them. The only file that I "lock" is the master lock
file and my program has to be able to "lock" the master file before access to
the data is permitted.

best wishes,

------------------
ian.cairns@gems6.gov.bc.ca

IP: Logged

Michael Mattias
Member
posted May 27, 2004 08:08 AM     Click Here to See the Profile for Michael Mattias     Edit/Delete Message   Reply w/Quote
>Tom she is my girlfriend, she connects from my computer,i helped her registering from my computer

You mean, she did register with her real name, real email address and otherwise followed all the published rules, and the webmaster made a unilateral and not doubt divinely inspired decision she was lying?

MCM


IP: Logged

Terry Fritts
Member
posted May 27, 2004 08:22 AM     Click Here to See the Profile for Terry Fritts     Edit/Delete Message   Reply w/Quote
quote:
Please make sure she knows this is a forum for PowerBASIC,
not "qbasic or any other basic language".

Doubt you need to worry much about her posting again.

IP: Logged

Tom Hanlin
Member
posted May 27, 2004 11:19 AM     Click Here to See the Profile for Tom Hanlin     Edit/Delete Message   Reply w/Quote
Divinity? No, Michael. Hadn't you heard? "To err is human."

It was an honest mistake, since corrected, made on the basis of a
great deal more experience dealing with pseudonyms than anyone would
ever want to acquire, and a wee bit more data than may be obvious.

------------------
Tom Hanlin
PowerBASIC Staff

IP: Logged

Clay Clear
Member
posted May 27, 2004 11:43 AM     Click Here to See the Profile for Clay Clear     Edit/Delete Message   Reply w/Quote
My name probably would have caused a bit of a fuss, too. If I had
not bought my first PowerBASIC product directly from PB, Inc. via
telephone to their sales dept. with my credit card (my credit card
was issued to my real name, which really is "Clay Clear"), Mr. Zale
et al probably would have been scandalized when they first saw a posting
from "Clay Clear" in these Forums. They have to make their decisions
regarding handles SOMEHOW, and such processes are prone to error
because of their nature. Fortunately, in my case, they were already
aware of my name, weird though it is, so there were no "misunderstandings".


------------------

IP: Logged


This topic is 2 pages long:   1  2 

All times are EasternTime (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | PowerBASIC BASIC Compilers

Copyright © 1999-2005 PowerBASIC, Inc. All Rights Reserved.


Ultimate Bulletin Board 5.45c