Autor Beitrag
Ebil
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131



BeitragVerfasst: So 29.06.08 20:53 
Hi leute,
Ich sitze grad an einer frage die mir schwierigkeiten bereitet, ich habe noch nie etwas mit datenbanken gemacht.
Ich schreibe ein programm das daten aus einem text file ausliest.
Eine zeile der "datenbank" sieht zb so aus.

ausblenden Quelltext
1:
ID,Sprite_Name,kROName,iROName,LV,HP,SP,EXP,JEXP,Range1,ATK1,ATK2,DEF,MDEF,STR,AGI,VIT,INT,DEX,LUK,Range2,Range3,Scale,Race,Element,Mode,Speed,aDelay,aMotion,dMotion,MEXP,ExpPer,MVP1id,MVP1per,MVP2id,MVP2per,MVP3id,MVP3per,Drop1id,Drop1per,Drop2id,Drop2per,Drop3id,Drop3per,Drop4id,Drop4per,Drop5id,Drop5per,Drop6id,Drop6per,Drop7id,Drop7per,Drop8id,Drop8per,Drop9id,Drop9per,DropCardid,DropCardper					


Dort stehen dann halt die jeweiligen werte, anstatt nun die bezeichnung.
Ich splitte den string anhand jedes "," und lese dann die einzelnen werte aus.

Nun ist mir eingefallen das es das ganze auch als SQL tables gibt

ausblenden volle Höhe SQL-Anweisung
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
DROP TABLE IF EXISTS `mob_db`;
CREATE TABLE `mob_db` (
  `ID` mediumint(9) unsigned NOT NULL default '0',
  `Sprite` text NOT NULL,
  `kName` text NOT NULL,
  `iName` text NOT NULL,
  `LV` tinyint(6) unsigned NOT NULL default '0',
  `HP` int(9) unsigned NOT NULL default '0',
  `SP` mediumint(9) unsigned NOT NULL default '0',
  `EXP` mediumint(9) unsigned NOT NULL default '0',
  `JEXP` mediumint(9) unsigned NOT NULL default '0',
  `Range1` tinyint(4) unsigned NOT NULL default '0',
  `ATK1` smallint(6) unsigned NOT NULL default '0',
  `ATK2` smallint(6) unsigned NOT NULL default '0',
  `DEF` smallint(6) unsigned NOT NULL default '0',
  `MDEF` smallint(6) unsigned NOT NULL default '0',
  `STR` tinyint(4) unsigned NOT NULL default '0',
  `AGI` tinyint(4) unsigned NOT NULL default '0',
  `VIT` tinyint(4) unsigned NOT NULL default '0',
  `INT` tinyint(4) unsigned NOT NULL default '0',
  `DEX` tinyint(4) unsigned NOT NULL default '0',
  `LUK` tinyint(4) unsigned NOT NULL default '0',
  `Range2` tinyint(4) unsigned NOT NULL default '0',
  `Range3` tinyint(4) unsigned NOT NULL default '0',
  `Scale` tinyint(4) unsigned NOT NULL default '0',
  `Race` tinyint(4) unsigned NOT NULL default '0',
  `Element` tinyint(4) unsigned NOT NULL default '0',
  `Mode` smallint(6) unsigned NOT NULL default '0',
  `Speed` smallint(6) unsigned NOT NULL default '0',
  `aDelay` smallint(6) unsigned NOT NULL default '0',
  `aMotion` smallint(6) unsigned NOT NULL default '0',
  `dMotion` smallint(6) unsigned NOT NULL default '0',
  `MEXP` mediumint(9) unsigned NOT NULL default '0',
  `ExpPer` smallint(9) unsigned NOT NULL default '0',
  `MVP1id` smallint(9) unsigned NOT NULL default '0',
  `MVP1per` smallint(9) unsigned NOT NULL default '0',
  `MVP2id` smallint(9) unsigned NOT NULL default '0',
  `MVP2per` smallint(9) unsigned NOT NULL default '0',
  `MVP3id` smallint(9) unsigned NOT NULL default '0',
  `MVP3per` smallint(9) unsigned NOT NULL default '0',
  `Drop1id` smallint(9) unsigned NOT NULL default '0',
  `Drop1per` smallint(9) unsigned NOT NULL default '0',
  `Drop2id` smallint(9) unsigned NOT NULL default '0',
  `Drop2per` smallint(9) unsigned NOT NULL default '0',
  `Drop3id` smallint(9) unsigned NOT NULL default '0',
  `Drop3per` smallint(9) unsigned NOT NULL default '0',
  `Drop4id` smallint(9) unsigned NOT NULL default '0',
  `Drop4per` smallint(9) unsigned NOT NULL default '0',
  `Drop5id` smallint(9) unsigned NOT NULL default '0',
  `Drop5per` smallint(9) unsigned NOT NULL default '0',
  `Drop6id` smallint(9) unsigned NOT NULL default '0',
  `Drop6per` smallint(9) unsigned NOT NULL default '0',
  `Drop7id` smallint(9) unsigned NOT NULL default '0',
  `Drop7per` smallint(9) unsigned NOT NULL default '0',
  `Drop8id` smallint(9) unsigned NOT NULL default '0',
  `Drop8per` smallint(9) unsigned NOT NULL default '0',
  `Drop9id` smallint(9) unsigned NOT NULL default '0',
  `Drop9per` smallint(9) unsigned NOT NULL default '0',
  `DropCardid` smallint(9) unsigned NOT NULL default '0',
  `DropCardper` smallint(9) unsigned NOT NULL default '0',
  PRIMARY KEY  (`ID`)
) TYPE=MyISAM;


Ein eintrag sieht dann ca so aus:

ausblenden SQL-Anweisung
1:
REPLACE INTO `mob_db` VALUES (1011,'CHONCHON','Chonchon','Chonchon',4,67,0,5,4,1,10,13,10,0,1,10,4,5,12,2,10,12,0,4,24,0x181,200,1076,576,480,0,0,0,0,0,0,0,0,998,50,935,6500,909,1500,1205,55,601,100,742,5,1002,150,0,0,0,0,4009,1);					


Was würde sich nun mehr lohnen? Ist SQL schneller/ressoucensparender? Und wieviel aufwand wäre es das ganze umzuschreiben?
Und wie nutze ich SQL? Muss dafür extra eine datenbank noch neben dem programm laufen? Müssen sich meine User extra kram installieren?
Bin grad echt nachdenklich, war ziemlich viel arbeit son doofen string zu zerlegen, und dann noch die eigenschaften ( zb element = 1,2,3,4,5,6.... und das den "namen" der elemente zuordnen...), war viel arbeit, aber wenn SQL besser ist, und es keine umstände für die user macht ( Und ich das mit so ner datenbank hinkrieg), würd ich mir denke ich mal die mühe machen...
Also bitte um hilfe ^^

Ebil

Moderiert von user profile iconKlabautermann: Code-Tag hinzugefügt.
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Mo 30.06.08 12:06 
Hi,

verstehe ich es richtig, momentan nutzt du noch Textdateien dafür?

In dem Fall währe eine Datenbank wahrscheinlich schneller, insbesondere dann, wenn es um große Datenmengen geht.
Eventuell hilft dir das hier als kleiner Einstieg um die Komplexität des ganzen besser abschätzen zu können.

Gruß
Klabautermann
Ebil Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131



BeitragVerfasst: Mo 30.06.08 12:41 
Hai, danke für deine antwort.

Das sieht ja schomal gut aus, und auch einfacher als ich es mit ner txt im moment hab.
Es würden am ende merhere txt alle so um die 500kb sein, mit denen gearbeitet wird.

Aber eine frage hätte ich noch, ich hab ja die mysql tabelle eigentlich schon ( wie im ersten post geschrieben) wie erzeuge ich damit die datenbank auf die ich dann zugreife?
Das programm sollte auch zur laufzeit die tabelle aktualisieren, ist das möglich?

Ebil
baka0815
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 489
Erhaltene Danke: 14

Win 10, Win 8, Debian GNU/Linux
Delphi 10.1 Berlin, Java, C#
BeitragVerfasst: Mo 30.06.08 12:47 
Wenn du MySQL benutzen möchtest, braucht der Benutzer einen eigenen MySQL Server. Kann zwar auf der selben Maschine wie das Programm laufen (braucht also keine extra Hardware), aber muss eben laufen.

Für deinen Zweck würde sich eine embedded DB anbieten, wie z.B. SQLite.
Wobei ich gerade sehe, dass es auch mit MySQL möglich sein soll.
Ebil Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131



BeitragVerfasst: Mo 30.06.08 16:05 
Habt ihr vllt ne schöne anleitung für sowas, BDE ist bei meinem delphi schon drin falls es wichtig ist, Firebird würd ich natürlich auch nehmen, mir isses eigentlich egal, denn ich stelle keine hohe anforderungen an die DB, hauptsache der User merkt nichts davon? MySQL kann ich im zusammenhang mit PHP schon, nur mit delphi nicht :/


Zuletzt bearbeitet von Ebil am Mo 30.06.08 18:41, insgesamt 1-mal bearbeitet
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 30.06.08 17:16 
Eine weitere skalierbare Lösung wäre FireBird (embedded)

_________________
Markus Kinzler.
Ebil Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131



BeitragVerfasst: Mo 30.06.08 19:26 
Oh gott, hab ausversehen mein alten post editiert ( so ist das wenn man 5 stunden weg is :D )
Der hier drüber:
"Habt ihr vllt ne schöne anleitung für sowas, BDE ist bei meinem delphi schon drin falls es wichtig ist, Firebird würd ich natürlich auch nehmen, mir isses eigentlich egal, denn ich stelle keine hohe anforderungen an die DB, hauptsache der User merkt nichts davon? MySQL kann ich im zusammenhang mit PHP schon, nur mit delphi nicht :/"
Sollte halt ne einfache datenbank sein, auch wenn es grad eins meiner größten projekte ist (für meine verhältnisse), kann man es nicht mit wirklich großen verlgeichen ^^
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 30.06.08 19:55 
sourceforge.net/proj...es.php?group_id=9028
Bei der embedded-Variante brauchst du nur die Client-Dll(S) ins Programmverzeichnis kopieren. Durch Ändern des Connection-String kannst du dann auf einen installierten Server zugreifen.
Als Zugriffskomponenten kannst du IBX, Zeos, UIB, MDO, IBDAC, FIBPlus, ... verwenden
Als Admintool z.B. die PE von IBExpert

_________________
Markus Kinzler.
Ebil Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131



BeitragVerfasst: Mo 30.06.08 20:58 
Das wird schon wieder ziemlich kompliziert :/ ne anleitung wär nich übel.
Schon doof das man wieder so viele kompos brauch :/.

Ebil
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 30.06.08 21:21 
IBX ist doch bei Delphi dabei
www.delphi-treff.de/tutorials/datenbanken/

_________________
Markus Kinzler.
Ebil Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131



BeitragVerfasst: Mo 30.06.08 22:22 
Von IBX find ich bei mir nix, und die tutorials kenn ich schon, leider kam ich damit nicht klar oder sie waren mir zu alt/hatte ne andere zusammenstellung.
Hab nun kompos für SQLite gefunden, sind mir leider auch zu alt von 2003, ich verstehs nich :D.
Find auch nix direkt für embedded datenbanken :/
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Mo 30.06.08 23:02 
user profile iconEbil hat folgendes geschrieben:
Von IBX find ich bei mir nix..


Das ist oben das "Interbase-Dingens".

user profile iconEbil hat folgendes geschrieben:
..Find auch nix direkt für embedded datenbanken :/


Das gibts nicht.

_________________
Gruß
Hansa
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 30.06.08 23:31 
Innerhalb der IDE heisst IBX z.B. Interbase Express oder Interbase.
Der Vorteil vin FB embedded ist es ja gerade, dass der Zugriff skalierbar ist. D.H der embedded-Zugriff unterscheidet sich nicht von dem Zugriff auf einen "Server"

_________________
Markus Kinzler.
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Di 01.07.08 16:31 
Hi,

da fangen wir doch mal ganz langsam an: user profile iconEbil Welche Delphi Version und Edition nutzt du?
Ebil Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131



BeitragVerfasst: Di 01.07.08 16:57 
Ich nutze delphi 2007 prof. aber trozdem find ich das interbase dingens nicht :/ Find nur BDE...
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Di 01.07.08 19:05 
s.Anhang
Einloggen, um Attachments anzusehen!
_________________
Markus Kinzler.
Ebil Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131



BeitragVerfasst: Di 01.07.08 19:28 
Ne sorry, gibts bei mir nicht, keine ahnung ob das normal ist ^^.

Also was bräuchte ich jetzt?

Sqlite?
dann noch Firebird (embedded?)
noch irgendwas?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Di 01.07.08 19:39 
Ist das entsprechendes Package installiert?
Einloggen, um Attachments anzusehen!
_________________
Markus Kinzler.
Ebil Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131



BeitragVerfasst: Di 01.07.08 20:59 
Danke, war schon ganze zeit nach dem package auf der suche, habs nun installiert und hab auch die komponenten, was brauch ich nun noch für ne embedded db?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Di 01.07.08 21:41 
-die embedded-Server-(Client-)Dll
-Admintool zum Erzeugen der DB und zum Testen
-auf dem Entwicklerrechner bietet sich die Installation des Servers an.

_________________
Markus Kinzler.