#1
Posted 25 July 2012 - 06:26 PM
Im also looking for help on this project. the more you help me on the forums and the more i need you to physically help me with this
#2
Posted 25 July 2012 - 07:21 PM
#3
Posted 25 July 2012 - 07:53 PM
craniumkid22, on 25 July 2012 - 07:21 PM, said:
#4
Posted 26 July 2012 - 01:41 AM
#5
#6
Posted 26 July 2012 - 05:22 AM
these two clowns are doing it wrong.
In order to figure out what you need to do you need to ask yourself "why?"
in this case the "why" is to have an organized list of information.
the "what" is that you are storing it in an indexable format.
how is going to be the tricky part.
You need to visualize the indices (plural index) and imagine how you are going to be able to use your database.
You want to access particular sections. How will they be named? I would do it in XYZ
X being topic
Y being age number
Z being the information
That's just me. I have a chronological memory.
This is about all that I can share on the subject as I've never actually coded a database. I can't imagine it being very enjoyable..but I think I might make one to store information on players and their offenses or accomplishments on my server ;]. That would allow me to actually allow people to inherit my server later on without me needing to tell them everything about everyone. I'm ranting. Good luck.
EDIT:
And by the way, if you are still looking for tips and tricks but you've written a lot of it; expect to have to rewrite it when you have an epiphany.
#7
Posted 26 July 2012 - 05:32 AM
Edit: Im working on something similar. Happy Coding
#8
Posted 26 July 2012 - 08:31 AM
local db={}
then you use variables to name subdivisions of the table so for example if you were documenting players:
term.clear()
term.setCursorPos(1,1)
write("LOGIN:nUsername: ")
local name=read()
if db[name]==nil or type(db[name])~="table" then
db[name]={}
end
if db[name]["password"]==nil then
term.clear()
term.setCursorPos(1,1)
print("Welcome new user!nEnter your new password: ")
password=read('*')
db[name]["password"]=password
end
db[name]["last_login_at"]=os.getComputerID()
etc. point is you use a table and then use variables to navigate it, you can have multiple terminals and set them to send all input to a server and they can request data etc, it gets fairly complicated when you make everything remote but yeah... pm me if you need any more specific examples
#9
Posted 26 July 2012 - 08:33 AM
#10
Posted 26 July 2012 - 02:02 PM
KingMachine, on 26 July 2012 - 05:22 AM, said:
these two clowns are doing it wrong.
Neither "clown" nor "doing it wrong" are applicable. The effort I'm willing to put in is directly dependent on the effort OP is willing to put in. Extraordinarily broad questions should get extraordinarily broad answers.
#11
Posted 27 July 2012 - 04:23 AM
Lyqyd, on 26 July 2012 - 02:02 PM, said:
KingMachine, on 26 July 2012 - 05:22 AM, said:
these two clowns are doing it wrong.
Neither "clown" nor "doing it wrong" are applicable. The effort I'm willing to put in is directly dependent on the effort OP is willing to put in. Extraordinarily broad questions should get extraordinarily broad answers.
I can agree with that. I retract my statement.
#12
Posted 05 November 2012 - 03:02 AM
["USER1"]{
ID: 1
NAME: "USER1"
AGE: ...
etc
}
#13
Posted 05 November 2012 - 06:45 AM
users = {
[John] = {ID = 1, Age = 23, --Space for additional stuff--}
[Steve] = {ID = 2, Age = 14, --Space for additional stuff--}
[Vanessa] = {ID = 3, Age = 17, --Space for additional stuff--}
}
#14
Posted 05 November 2012 - 11:41 AM
buttons = {
[1] = {
visible = true,
text = hi,
command = hello
}
}
That is the basics of it.
#15
Posted 22 December 2012 - 02:21 PM
One difference between the two that I can think of I think you want to carry over or test out in your CC setup - row locking.
Now to start with, all data should be kept in tables. By keeping variables defined as their authentic types in Lua, you do not need to worry about converting any back and forth between your application and the storage.
In addition this allows you to very easily store them to the file system without having to design a format of your own. You can just serialize the tables using textutils.serialize(), and unserialize them when you load them back up. It provides minimal system load and again you're not taking unnecessary steps that could damage your data's integrity.
However databases can get very large, and there are two approaches I can envision that would resemble the two DBS' just mentioned:
- Loading the stored data upon startup, keeping all of it in active memory, processing queries with the data from memory and writing it to the disk periodically/on shutdown.
This would more resemble MyISAM, as it would involve a form of table locking versus row locking in the example I'll give you next. I can see definite merit in lowering the quantity of (CPU intensive) read/write operations to the disk, but as the tables fill up they'll start hogging the server's memory. It depends on how much data you want to store.
- Indexing all databases as seperate folders, and within them all data tables. Within the table folders store serialized Lua tables that represent each individual row
This would lean more towards InnoDB in terms of only opening up required rows. If lots of write operations occur it may be heavy on the server, but at the same time the principle of row locking involves writing each data table row separately as this means multiple rows can be affected simultaniously without conflicts.
In addition, seeing as how we're talking about CC computers, you would spare the server's RAM by not keeping all of the data in active memory constantly, and indexing would still be a sinch since you can simply save the serialized rows to files named after their ID number.
Just some musings. However, the hard part will be making a query language.
#16
Posted 22 December 2012 - 05:36 PM
#17
Posted 23 December 2012 - 01:20 AM
#18
Posted 23 December 2012 - 02:04 AM
#19
Posted 23 December 2012 - 07:34 AM
#20
Posted 28 January 2013 - 06:47 AM
if u don't know how mongo works, this article - http://horicky.blogs...chitecture.html - should help you understand...
i am working on simplified for computercraft noSQL database api to store simple informations about turtle, computers and chests(like its position, number of slots avaible and how many items in each slots etc...)
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











