Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 4 Jahren, 5 Monaten
Letzter Beitrag:
vor 4 Jahren, 3 Monaten
Beteiligte Autoren:
tobi_from_HH, Allard, Al, Stefan Bentvelsen, Charles U. Schneiter, DarrenF

[WD17] New datafile from a preset datafile

Startbeitrag von tobi_from_HH am 11.10.2013 10:32


How can I create datafiles from a preset datafile. I need to save always the same types of data like books (title, author, ISBN and so on) but I want to save the books based on the publisher. So publisher A is a datafile of books, publisher B is a datafile of books an so on.

Hope you can help me. Thanks



Hi Tobi,

Not sure, if I completely understand your question, but here goes anyway:

IMO you wouldn't need a separate file per publisher at all - at least I can't find a reason to do this but stand happily corrected :)

Wouldn't you rather normalize the data by:
- creating a file called publisher with a primary key of PublisherID
- adding PublisherID as a foreign key to the existing 'Books' file
- creating a link (relationship) between these two files, based on PublisherID
__ - A Publisher can have 0 to n books (0:n)
__ - A given Book can have a minimum and maximum of 1 Publisher (1:1)

Having a separate file per publisher will give you some headache later on, being it with searching, the reports or even data consistency (e.g. a book can quite often be published by more than one Publisher...) etc.

With the above solution you hold all books in one file and by using PublisherID as a selection criteria, you can easily distinguish between publishers..


Just my 2 cts plus tax

von Charles U. Schneiter - am 11.10.2013 12:42
Hi Tobi,

if you really want separate files for each publisher, you can define one file in the analysis and use HAlias (+ HChangeName() / HChangeDir()) to create different files with the same structure.

von Stefan Bentvelsen - am 11.10.2013 14:45

Charles is correct!

Just in the same way that you wouldn't have an invoice header table and many individual files containing invoice lines, you must have one file for all the publishers and link them to the file containing all the books via a foreign key.

von DarrenF - am 11.10.2013 23:21
Thanks for your answers. I uses now the method from Charles.

Now I linked the datafile with the books to a table. The table displays all books. But how can I display only the books of one publisher?

Thanks for an answer.


von tobi_from_HH - am 29.11.2013 14:14
Hello Tobi

If you have a file of publishers with a primary key for each publisher, then the book file is linked to that file using the publisher primary key as its publisher foreign key, so to show books for a single publisher, all you need to do is query or a use Hfilter() on the book file to build a table of books where the book file publisher foreign key matches the designated publisher primary key.


von Al - am 29.11.2013 14:31
Hi Tobi
You can fill the table by programming or fill it with a query . Several options are possible

Simple code example to get the table to display books of a certain Publisher :

For each book WHERE book.bookID = ComboBox - Publisher
Tableaddline(tablename, Book.name, BookPrice, etc, etc ( for table by programming)
Or tabledisplay( tablename) (for a table on file or query)

The combo would than hold the publisher file (publisher .bookID). If you put the code in the “on change “setting of the combo-box then you can select a publisher and all books will be shown in the table
It’s probably better to take a look at the tutorial and just read and do it. Takes a day or two but after that you get the concept and these kind off issues or solved in minutes.



von Allard - am 30.11.2013 02:38
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.