Re: Embedded SQL in C#
"VictorReinhart " <victora.reinha rt@phs.com> wrote in message
news:1135893781 .390492.92280@o 13g2000cwo.goog legroups.com...[color=blue]
> <<I may not know your exact circumstances, but I do not see how saving
> a few
> minutes by writing one line to talk to the database rather than a few
> lines
> is going to affect the budget. But then that is just me.>>
>
> My application has about 250 tables. That's not unusual. I have
> worked on numerous business applications with 250 to 400 tables or
> more. With that many tables, there is going to be a lot of SQL to
> insert, delete, update and select from all those tables.
>
> That is very, very common.[/color]
Yes it is.
[color=blue]
>
> So, there is going to be a lot of C# code declaring parameters, etc.[/color]
Which Visual Studio or any number of tools can automate for you.
[color=blue]
>
> Further, these tables are frequently joined. Frequently, these are
> non-trivial joins, with 3 to 6 tables or even more. Sometimes, we even
> join views. Very often, we use a combination of outer joins with inner
> joins. Very often, there are bugs in these queries. Also, these
> queries tend to require maintenance -- adding colums, adding tables,
> changing the WHERE clause.
>[/color]
Which is one of the reasons embedding non-trivial SQL in applciation code,
whether using dynamic SQL or static embedded SQL is a bad idea. Non-trivial
SQL statements belong in the database, not the application. An application
should be coded against a simple service layer in the database consisting of
single table and view access and stored procedures. If you need to join
multiple tables and do non-trivial SQL, it's much easier to code, debug,
maintain and port it at the database tier.
I'm pretty liberal about allowing SQL in an application. My simple rule for
SQL in the application tier is simple: no joins. If you need a join, code
it in a view, procedure, UDF, etc and call it from client code. The need
for client code to join indicates that your data model is exposed with too
much granularity, and your application has too much knoledge about the
details of your relational schema design.
Embedding SQL in the application simply violates the seperation of tiers,
technologies and developer skill-sets which is the foundation of enterprise
application architecture. It works for simple applications, but in
substantial enterprise applications with lots of tables, lots of business
rules, lots of technical roles, etc, it just won't do.
David
"VictorReinhart " <victora.reinha rt@phs.com> wrote in message
news:1135893781 .390492.92280@o 13g2000cwo.goog legroups.com...[color=blue]
> <<I may not know your exact circumstances, but I do not see how saving
> a few
> minutes by writing one line to talk to the database rather than a few
> lines
> is going to affect the budget. But then that is just me.>>
>
> My application has about 250 tables. That's not unusual. I have
> worked on numerous business applications with 250 to 400 tables or
> more. With that many tables, there is going to be a lot of SQL to
> insert, delete, update and select from all those tables.
>
> That is very, very common.[/color]
Yes it is.
[color=blue]
>
> So, there is going to be a lot of C# code declaring parameters, etc.[/color]
Which Visual Studio or any number of tools can automate for you.
[color=blue]
>
> Further, these tables are frequently joined. Frequently, these are
> non-trivial joins, with 3 to 6 tables or even more. Sometimes, we even
> join views. Very often, we use a combination of outer joins with inner
> joins. Very often, there are bugs in these queries. Also, these
> queries tend to require maintenance -- adding colums, adding tables,
> changing the WHERE clause.
>[/color]
Which is one of the reasons embedding non-trivial SQL in applciation code,
whether using dynamic SQL or static embedded SQL is a bad idea. Non-trivial
SQL statements belong in the database, not the application. An application
should be coded against a simple service layer in the database consisting of
single table and view access and stored procedures. If you need to join
multiple tables and do non-trivial SQL, it's much easier to code, debug,
maintain and port it at the database tier.
I'm pretty liberal about allowing SQL in an application. My simple rule for
SQL in the application tier is simple: no joins. If you need a join, code
it in a view, procedure, UDF, etc and call it from client code. The need
for client code to join indicates that your data model is exposed with too
much granularity, and your application has too much knoledge about the
details of your relational schema design.
Embedding SQL in the application simply violates the seperation of tiers,
technologies and developer skill-sets which is the foundation of enterprise
application architecture. It works for simple applications, but in
substantial enterprise applications with lots of tables, lots of business
rules, lots of technical roles, etc, it just won't do.
David
Comment