. Subject: Re: libreoffice-users Adding fields to existing Base table.
From: Paul. Date: Thu, 10 Jul 2014 23:26:15 +0200. To:Hi Dave,Having worked as a business systems designer and coder, I've dealt withdatabases and database changes a lot. And the users always end upchanging stuff later. Some of what I am going to say may be obvious orstuff you already know; if so I apologise, but your question makes itseem like you are unfamiliar with databases, so I will try to cover thebasics.The short answer is that this sort of thing is done all the time,applies to all databases, and is pretty easy stuff, if somewhattimeconsuming for the client, unless there are complicating factors.At least, pretty easy just from the database side of things, I'm notsure if LO makes it harder than it should be, as I haven't used LO Basemuch. I'm mainly talking about the underlying principles here, whichyour post suggested to me that you don't fully understand yet (again,sorry if I got that wrong).The long answer.First off, if your database may grow to 3 Gb, it suggests that this maybe a serious application. A rough guesstimate suggests maybe a millionrows, and that sort of growth in a year means about 8 rows a minuteadded (very rough guesses, but just to get an idea of the scale weare talking about).
I would think carefully now, rather than investigateat some later date. As often happens, you could end up with the clientdeciding that it's not worth the cost of making a change, and whateverpoor choices you made up front 'just for now' end up sticking with youand being a major headache when things get beyond their capabilities.Straight away I question using LO at all. A custom front-end often hasmany advantages in this sort of situation, making them worth the cost.But that's the sort of thing I used to do for a living, so I guessthat's my instinctive response, not to say LO isn't a good fit forthis; I don't know the requirements, so I can't say.But at the very least, I would.strongly. suggest using an externaldatabase, not the built-in HSQLDB.With a good backup solution.And consider where it will be hosted. If the database is that big, youneed to consider questions like how many people will be using it at thesame time, and how many transactions will be occuring per second.
Thehardware used for the database server makes a big difference to theresponsiveness of these sorts of systems.As to adding fields, you just got to live with that one. Happens allthe time. No amount of getting the client to think carefully about hisdesign is going to prevent them coming later and wanting stuff changed.So says my experience.Luckily it's not hard to do, per se.
The problem is of course that ifyou add fields, you are adding them to the structure of the table,which determines what will be in each row, so it affects not only rowsthat will be added but also all already existing rows. And thereforeeach existing row needs to have something (even if the something isnothing) in that new field. That will always be a problem. Luckily,mostly a problem for the client, who now has to go back and add all thatmissing info for the existing rows, to make sure that the data in thedatabase makes sense.So when you say that the docs said it might be painful, that's not somuch from the practical point of actually adding the fields, but fromthe point of making the existing rows make sense with the newinformation.
So yes, it applies for all databases. They all makeactually adding the new field pretty much just as easy, but thereconciling the existing rows has nothing to do with the database andeverything to do with the data itself.When adding new fields, as with adding fields at the beginning whendesigning the table, you can choose both a default value for a field,and to allow the field to be null. Nulls are misused and abused a lot,and different people have different ideas about how to use them. It's awhole other topic to explain how to use nulls properly, but suffice tosay that when you add a field to a table, you can allow the field to benull, and then all existing rows in the table will simply have null forthat field. Or, you could choose a default value for the field, andthen all existing rows in the table will have the default value forthat new field. That value could be a blank value, like an emptystring, which is different to a null value.So for simple additions of information, the developer's job is prettystraightforward.
Yes, you have to add that field to the table, and thento all forms and reports, but it is the client who has to make sure allthe new and existing entries have valid information in that new field.The problem for you as a developer comes in when they want additionalfunctionality tied in to that field. Given that you're developing thisin LO, I'm guessing that there won't be too much of this, it willmostly be simple informational fields.
But some of the stuff I've donein the past has required things like 'when they fill in this field,they must get this custom screen to choose a value from, and then, ifthey choose 'A', they must get this custom icon on the report, and ifthey choose 'B', then this mustn't show up on the report at all, andinstead must make one of the other rows show up differently'. Ok, notactually anything like that, but you get the picture. That's someserious developer headache there.As to deleting fields, it's also pretty easy. You just drop the field,and the field is gone from all existing rows. Which means loss of somedata. Which presumably is what you want.
Provided, of course, there areno other considerations, like other tables linking to this table viathe field. Then it gets a little trickier, and really depends on whatyou want to do.Sorry if this post was rather long, but I hope it showed you the basicfactors you need to consider with the database design.PaulOn Thu, 10 Jul 2014 15:27:27 -0400dave boland wrote: I'm setting up a database that is small (three tables, may grow to 3GB over next year).
I need a strategy to deal with the unknown, which is how to add fields to an existing table. I read in the docs that doing this can be painful and it is required to put something in each field for each record. Do I have this correct? If so, how do I handle the inevitable '.would you add.'
That is sure to come within the next few months? I would add them now, but I really can't anticipate how many fields will be added or their requirements. In general, do other databases have similar restrictions? At some time, when I have time, I will consider MySQL, MariaDB, and others. Thanks, Dave-To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.orgProblems?Posting guidelines + more:List archive:All messages sent to this list will be publicly archived and cannot be deleted.
Copyright information: Unless otherwise specified, all text and images on this website are licensed under the. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License. 'LibreOffice' and 'The Document Foundation' are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our.
Last addedDatePascal Analyzer 9.6.0.02019-12-06PDF Combine 7.1.0.102019-12-06Pascal Analyzer Lite 9.6.0.02019-12-06Photo Supreme 5.2.0 Build 25702019-12-06PixelShift to DNG 0.9.18 Build 92 RC2019-12-06Lianja ODBC Data Source Manager 5.0.12019-12-06WinCompose 0.9.42019-12-06Metasploit Framework 5.0.642019-12-06XLStat 2019.4.1 Build 632322019-12-06Perfectly Clear Photoshop Plugin 3.9.0.17052019-12-06Norton AntiVirus Virus Definitions December 06, 20192019-12-06Lianja App Center 5.0.12019-12-061. Free program lastbit password tools v11.0.8051 h33t original free.
I have the following reference table (treatment) - extract as follows:On a form, to record treatment for an animal (dog) in table 'dogtreatment', I have 2 combo boxes, the first to select 'treatmenttype' (SELECT DISTINCT ('treatmenttype') FROM 'treatment') and the second 'treatmentsubtype' (SELECT DISTINCT('treatmentsubtype') FROM 'treatment'). Obviously subtype is dependent on the first selection (type) and I would like to use the value selected in the first combo box as a filter in the 2nd SELECT statement, something like: SELECT DISTINCT('treatmentsubtype') FROM 'treatment' WHERE 'treatmenttype' = ComBoxTreatmentTypeI have read numerous posts, including the following and it's associated links and database:(rudolfo (in the above post) says '. You need some programming experience because most probably you will have to make some modifications to match it on you environment. And without experience (including debugging a macro) this will all be like chinese for you.' And it is!Ultimately, this is 'nice to have' feature, as the combination of 'treatmenttype' and 'treatmentsubtype' is a PK in table 'treatment' (& FK in table 'dogtreatment') which prevents the user from entering an incorrect type/subtype combination.
It would simply reduce the number of subtypes available for selection within the 2nd combo box. Edited 1/17/2017 - Additional sample at end of answer.Hello,First let me state the answer by is valid (+1).Filtering can be done with & without macros. I have posted 10 to 20 on this forum using many variations. There is also you may want to look at.With that said, here is what I see in your question. You do not really need combo boxes for new treatments. If it isn't in the 'treatment' table it needs to be added there for a centralization of items.
Next is that you are working on the probability that an animal will receive more than one treatment at the same time so possibly using a Table control for data entry and history may be the method of choice. This is where the problem arises. You can certainly have list boxes in a table control.
What I haven't seen is a table control with one list box based upon another in the same record. The question has previously arisen & I have finally came to somewhat of a solution.
It does, however, utilize two small macros. While small, to someone not accustomed to macros they are quite large (as you have mentioned).Here is a sample containing the form with a Table Control. It is somewhat based upon your needs as I created it from a previous answer for you. The DogTreatments form is simple to use. Use the listbox on top left to select a 'dog' then press button (Select Dog) which then lists all previous treatments for that animal. New items can be added at the end of the table.
'treatmenttype' and 'treatmentsubtype' are both listboxes. A selection in 'type' will show only related selections in 'subtype'. On a NEW record, nothing will show in 'subtype' until a 'type' is selected.Sample -This is revised copy (1/17/2017) correcting error on new entries. 'subtype' listbox had incorrect display. Macro code below modified with corrections.
Since these are combo boxes, the second list is not limited to the filtered values, correct? In other words, other values can optionally be entered that are not in the list.
More commonly, I have seen filtered list boxes in this type of setup to prevent values from being entered which do not match.One solution is to use a FilterCriteria table. When the first combo box is changed, a macro enters values into the table, and the second combo box is filtered based on the table.A detailed example that stores the results of both boxes into the main table of the form is given in my edited answer at.