Some practical questions, tehniques

klodoma

New Member
Hi to all,

I am new to progress and I have some questions to which I dind't find the answer yet:

1. How can I assign a sequence to a table field automatically?
Like an autoincrement or serial or sequence(that's how they are called in other DB's).

2. How do I make a foreign key?(or a reference to another table) and how are the rules created? On update/on delete/ on insert etc.

What other practices are working in progress to make data in database consistent!? ... I mean if a key i referenced in another table, that I constraint that that key cannot be deleted/updated. We have some data inconstencies and I would like to solve them.


I faced a lot of memory limitations, like you cannot create a very large array, in v9 the strings are limited to 32kb, from what I read in 10 there is the LongString that does not have this limitation... will these be removed in future? (...we live in 2008)

Regards,
Andy.
 

parul

Member
You have to assign the sequence to a database field.
Functions like current-value, next-value are used for it. You can find more information in programing handbook under database access section there is a section that talks about sequences.

In progress data integrity is maintained using database triggers.
You have to program each condition (It can be good or bad depends on the way you see it).

-Parul.
 

klodoma

New Member
You have to assign the sequence to a database field.

Is it possible to say for a DB field to say: default value = NEXT-Value(Sequence)? Will this work?

I don't want to control sequence value from the application, just from the DB.

Andy.
 

parul

Member
You can say this in the create trigger of that table.
table.field = next-value(sequence).
but again database trigger code is not stored in "database" but is stored in a file.

It is also good not to use Database to store things like validations, view-as etc since it is difficult to change it.

-Parul.
 

Prajan

New Member
How do I make a foreign key?(or a reference to another table) and how are the rules created? On update/on delete/ on insert etc

You can make multiple keys in the tables created (Go to Create Index in Index icon). The other key except the primary key is unique, active. Rules are created when u move to field properties (Go to Field Icon) and go to fill the validation filed after clicking validation button.
 

tamhas

ProgressTalk.com Sponsor
There is a theme here which you should note for writing good ABL. In other languages and databases there is a tradition of putting various kinds of data constraints on the database -- autoincrement fields, join constraints, key constraints, delete constraints, etc. -- along with significant use of stored procedures for more sophisticated processing. Some of these appear to have appeal because they centralize and enforce relational integrity and they provide good performance in client/server configurations. However, we are supposed to be beyond client/server these days and into layered architectures. In such architectures, it is preferable to centralize all these integrity constraints and special processing in a data access layer because then all logic related to the data is in one place.
 

klodoma

New Member
...and special processing in a data access layer because then all logic related to the data is in one place.

What do you really understand by data access layer?


From what I noticed, there is the application and the database. In progress there are "somehow" more or less related. But the same DB can be used by more apps.

Anyway, I would like to guarantee the data consistency through the database(with triggers, with constraints, sequences etc) and NOT through the application (this is how it's made now and it's messy).
 

Casper

ProgressTalk.com Moderator
Staff member
What do you really understand by data access layer?

Tamhas has AFAIK not exactly the same aproach and ideas as Progress has, but if you are really interested maybe these doucments will give you an idea.

http://www.psdn.com/library/kbcategory.jspa?categoryID=54

From what I noticed, there is the application and the database. In progress there are "somehow" more or less related. But the same DB can be used by more apps.

IMO from a design point of view it isn't very wise to build different applications on one datamodel. But maybe your definition of apllication is different then mine....


Anyway, I would like to guarantee the data consistency through the database(with triggers, with constraints, sequences etc) and NOT through the application (this is how it's made now and it's messy).

Wether or not it is messy all depends on how it is implemented. I think that a better argument for (enforced) referential integrity will be performance. But that is my opinion.
Referential integrity doesn't protect you from making a bad database design.


My thoughts on this,

Regards,

Casper.
 

tamhas

ProgressTalk.com Sponsor
You have a little catching up to do on the last 15 years or so of application architecture. Even with client/server there is a division in the application and each part is running on a different processor. With a truly layered or distributed application, there many be many processors involved in the solution, even not counting the clients. The data access layer lives next to the database, most often on the same machine and all other parts of the application access the data by accessing that layer rather than accessing the database directly. Among other things, this allows the entire remainder of the application to be OO even though the persistence is in an RDBMS.

I see that Casper has pointed you at some of the PSDN materials. That would be a good start, but you also might want to check out http://www.oehive.org/OERAStrategies for a different twist on some aspects and the PSDN OERA forums for discussions. You also might want to read up a bit on SOA and ESB to get really modern.
 

klodoma

New Member
This is maybe off topic and I don't want to hurt nobody's feelings, but if there is still a "question" of using OO or not to use OO... I feel sorry for the progress "mass". I come from Visual C, .Net and PHP field, I developed web and desktop applications and honestly I feel like jumping back some years...

Anyway, about writing good OO or not... you can same the same about writing good NOO or not... it is just a skill and knowledge problem. In my view OO has a MAJOR advandtage over NOO. (and from what I saw this is a major issue in Progress, code reusability)

But... this is another discution, I dont want to talk about it here, I saw that there are other threads where we can discuss these.
 
This is maybe off topic and I don't want to hurt nobody's feelings, but if there is still a "question" of using OO or not to use OO... I feel sorry for the progress "mass".

Although I have little practical experience with OO and should therefore maybe not comment (though I've read all the books, got the T-Shirts, seen them live, etc.), I agree with your point here.

Given that almost all modern languages are OO-based, or extended (including Progress now), the onus is on non-OO programmers (eg. most Progress programmers) to say why this is not the way forward should there be a discussion. OO is not a programming fad that came and went.

But it would be worth you getting to understand the 4GL (as you say, you are a newbie to it), and particularly its power with respect to creating CRUD applications before dismissing it.

When you have that expertise, I would be very interested in reading your comments on 'the Progress way', and it's benefits and disadvantages.
 
Top