Reputation: 418
Is there an equivalent of using C# interfaces on the iSeries using DDS. For example, let's say I have this...
Person
------
name
address
Teacher : Person
-------
school
Policewoman : Person
-----------
weapon
... where a teacher and policewoman both are persons, but have additional fields...
In C# you would declare Person and then both Teacher and Policewoman would implement person as an interface.
How would I do this in DDS on the iSeries? I'm looking for something I can stick into the DDS for the Teacher and Policewoman files that would point to the Person file and know that name and address are fields of Teacher and Policewoman.
Thanks in advance.
Upvotes: 0
Views: 117
Reputation: 64
You can use C# built in Visual studio that will connect to an AS400 with ODBC.
The native 400 DDS file has fields, like Access. you can load those fields in a record. You would then use an SQL connection to the 400 in your C# design.
You can read a record from the 400 file, build column/row recs in DataGridView,
load the field values from the 400 rec into the DataGridView... then BANG! Pop the DataGridView in your form. A little coding with C# for INSERT & DELETE, youre home free. As long as the DDS exists on the 400, you can connect to it with ODBC and give the user a "PC" interface feel.
Upvotes: 0
Reputation: 676
First of all, we've recommend our customers use SQL DDL instead of native DDS for some time now: http://www.ibmsystemsmag.com/ibmi/developer/modernization/A-Debate--DDS-vs--DDL/
To answer your question, though, for this type of table "inheritance" structure we can model it using an ISA relationship in an ER diagram. You can see the answer for a similar question here: Entity Relationship Diagram. How does the IS A relationship translate into tables?
Basically, you'd do something like this:
CREATE TABLE PEOPLE(
ID INTEGER,
NAME VARCHAR(20),
ADDRESS VARCHAR(200),
PRIMARY KEY(ID));
CREATE TABLE TEACHERS(
ID INTEGER,
SCHOOL VARCHAR(20),
FOREIGN KEY(ID) REFERENCES PEOPLE(ID));
CREATE TABLE POLICE_OFFICERS(
ID INTEGER,
WEAPON VARCHAR(10),
FOREIGN KEY(ID) REFERENCES PEOPLE(ID));
Then you'd just join PEOPLE
with TEACHERS
with POLICE_OFFICERS
as appropriate to get all the additional fields.
Upvotes: 2
Reputation: 5651
You can't native use a C# style interface on IBM midrange.
You can code a java interface and implement that interface in a java class.
in DDS you can't do interfaces because interfaces are methods and properties tables are rows and columns.
Upvotes: 0
Reputation: 23803
I don't know of any relational DBMS that supports inheritance.
Closest thing would be via standard SQL DDL (not DDS)
CREATE TABLE Teacher LIKE Person;
ALTER TABLE Teacher
ADD COLUMN school char(30);
Using DDS, all you can do is use Person as a reference for the fields in Teacher
A REF(PERSON)
A R TEACHERR
A NAME R
A ADDRESS R
A SCHOOL 30A
However, there's a fundamental difference between RDBMS and OO languages such as C#. Tieing the two together is the purpose of Object / Relational Mapping (ORM)
Upvotes: 1