Showing posts with label model. Show all posts
Showing posts with label model. Show all posts

Monday, March 26, 2012

Relational Model and XML

Hi,

This question has been bothering me for some time. A lot of people
seem to "think" XML is the king of data problems, and I've heard that
next version of SQL Server is going to have a strong XML flavor,
meantime, I seem to get the impression that a large number of
hard-core relational model gurus do not seem to be that impressed with
XML (technical value of this extra layer seems to be limited while
business value might be substantial for instance, more software work,
more disk space requirement etc. etc.). What's your take on this?
Generality or specifics, all welcome. One specific question is, how
can XML supplement relational model?

Thanks.Doug Baroter (qwert12345@.boxfrog.com) writes:
> This question has been bothering me for some time. A lot of people
> seem to "think" XML is the king of data problems, and I've heard that
> next version of SQL Server is going to have a strong XML flavor,
> meantime, I seem to get the impression that a large number of
> hard-core relational model gurus do not seem to be that impressed with
> XML (technical value of this extra layer seems to be limited while
> business value might be substantial for instance, more software work,
> more disk space requirement etc. etc.). What's your take on this?
> Generality or specifics, all welcome. One specific question is, how
> can XML supplement relational model?

A broad question, but XML seems to have its place. The point where XML
is really meaningful is data exchange. A database is a bunch of
tables, but they just sit in one place, and don't travel around. But
the data in them do. While XML may be bulky and lot of overhead in
bytes, it has the nice property that it defines a standard framework
that you can put your data into.

A nice side benefit of this, is that with XML we suddenly have
gotten a method of inserting lots of data into SQL Server with
just one roundtrip on the network: send down the XML document,
and then say INSERT ... OPENXML.

Then in Yukon they are taking it even further with adding Xquery,
you have systemm functions that return XML data etc. Maybe MS is
taking it a bit too far, but XML is here to stay.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||>> What's your take on this? Generality or specifics, all welcome. <<

There is lot of research work (esp. papers at SIGMOD, DBPL etc on XML
suggests ) going on in the field of XML, but I am not sure if anything
positive has been established to consider XML as a data model alternative.

Vendors provide the consumers what they ask for, not what is empirical
and/or principled. When competition and customer retention become deciding
factors, often technologies that are obsolete, gets revived with minor
changes, under new terminologies. That is how the all profit-based
industries, including the IT industry, work.

>> One specific question is, how can XML supplement relational model? <<

The fundamentals of data management clearly tell me that Relational model
needs no supplementation by "XML" for anything relevant. However, it is
confusing that so many press articles on the topic are filled with
exaggerations and techno-tyros, who cannot distinguish a data exchange
technology from a data model, opining about XML going to change the world
overnight.

--
- Anith
( Please reply to newsgroups only )|||Yes, this is really nice because the user still only has to have
permission to execute the stored procedure. :)

Actually I found a problem with OPENXML that I've been meaning to
post. We have legacy flat-file systems (which of course we want to
replace, but we can't just snap our fingers and bingo it's done) that
use the equivalent of a char field for various numeric-appearing
identifiers such as our contract numbers. So for example, the
contract number field in the legacy system is 10 characters, but right
now we're still in the 700000's so it shows up as four spaces followed
by six numeric characters. OPENXML eats all the leading spaces
(Before you ask, yes, I am enclosing each attribute in quotes), so
then afterwards I have to reinsert them with an UPDATE statement if I
want the systems to talk to each other.

Any thoughts?

On Sun, 28 Dec 2003 23:47:25 +0000 (UTC), Erland Sommarskog
<sommar@.algonet.se> wrote:

>A nice side benefit of this, is that with XML we suddenly have
>gotten a method of inserting lots of data into SQL Server with
>just one roundtrip on the network: send down the XML document,
>and then say INSERT ... OPENXML.|||Erland Sommarskog <sommar@.algonet.se> wrote in message
> The point where XML is really meaningful is data exchange.
My point as well or agree whole-heartedly.

> A nice side benefit of this, is that with XML we suddenly have
> gotten a method of inserting lots of data into SQL Server with
> just one roundtrip on the network: send down the XML document,
> and then say INSERT ... OPENXML.
Wouldn't that require a lot of parsing especially considering
one-to-many relationships, binary objects etc. So, in that sense, not
necessarily "nice", IMHO.

> Then in Yukon they are taking it even further with adding Xquery,
> you have systemm functions that return XML data etc.
That's my sentiment as well.

>Maybe MS is
> taking it a bit too far, but XML is here to stay.
Thanks for your opinion. BTW, I forgot to add quotes for "business
value" in my original posting which could be misleading.|||I did not phrase my question correctly, which should have been "Would
XML add substantial value to data management?" I guess you would say
"No" while many other so-called forward-looking people may say "Yes".
I share your sentiment.

> The fundamentals of data management clearly tell me that Relational model
> needs no supplementation by "XML" for anything relevant. However, it is
> confusing that so many press articles on the topic are filled with
> exaggerations and techno-tyros, who cannot distinguish a data exchange
> technology from a data model, opining about XML going to change the world
> overnight.|||Ellen K. (72322.enno.esspeeayem.1016@.compuserve.com) writes:
> So for example, the contract number field in the legacy system is 10
> characters, but right now we're still in the 700000's so it shows up as
> four spaces followed by six numeric characters. OPENXML eats all the
> leading spaces (Before you ask, yes, I am enclosing each attribute in
> quotes), so then afterwards I have to reinsert them with an UPDATE
> statement if I want the systems to talk to each other.

I would guess that is part of the XML specification, but I'm not very
well versed in XML. However, this little snippet may help you to restore
the spaces directly:

create table #h (g char(10) NOT NULL)
go
declare @.xml nvarchar(4000), @.d int
select @.xml = '<H><B g=" 123456"/><B g="1234567890"/></H>'
exec sp_xml_preparedocument @.d output, @.xml
insert #h(g)
SELECT replicate(' ', 10 - len(g)) + g
FROM OPENXML(@.d, '/H/B', 1) WITH (g char(10)) AS x
exec sp_xml_removedocument @.d
select '<' + g + '>' FROM #h
go
drop table #h

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Doug Baroter (qwert12345@.boxfrog.com) writes:
> Wouldn't that require a lot of parsing especially considering
> one-to-many relationships, binary objects etc. So, in that sense, not
> necessarily "nice", IMHO.

Of course the parsing requires some CPU. But with today's CPU's I don't
think is a major issue. Network round-trips can easily be more expensive,
not the least on a busy network. And not the least 5000 individual
INSERT statements for each row rather than one for each table.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Erland Sommarskog <sommar@.algonet.se> wrote in message news:<Xns9460F25E5D928Yazorman@.127.0.0.1>...
> Of course the parsing requires some CPU. But with today's CPU's I don't
> think is a major issue. Network round-trips can easily be more expensive,
> not the least on a busy network. And not the least 5000 individual
> INSERT statements for each row rather than one for each table.

But with today's network speed, it used to be 10 MBPS, nowdays
standard 100 MBPS, in some environment, much greater than 100 MBPS;
simultaneous 1000 INSERTs into the same table at a given second would
seem to be rare even for a Fortune 100 company, hence, transaction
speed improvement does not seem to be that a big deal. Having said
that, I agree your arguement has a valid point.
Now, a totally separate question if you don't mind, probably you've
designed a stock trading system of your own, and I would think you've
been quite sucessful in doing that, do you take a student or two
occasionally?|||I have a batch process that runs every night which creates and then
inserts between 2000 and 5000 rows to a particular table, and I do it
with XML for exactly the reason Erland states, I don't want to make
all those roundtrips. We are nowhere NEAR Fortune 100, revenues are
less than $100MM.

On 29 Dec 2003 19:13:42 -0800, qwert12345@.boxfrog.com (Doug Baroter)
wrote:

>simultaneous 1000 INSERTs into the same table at a given second would
>seem to be rare even for a Fortune 100 company, hence, transaction
>speed improvement does not seem to be that a big deal.|||I'm not well-versed either, in fact I create the XML document by
<red-face emoticon> building a giant string. However, I sure like
being able to get 5000 rows across the network and into my table in
ONE SECOND. :)

I'm going to send myself the below and experiment with it at work,
thanks very much. :)

On Mon, 29 Dec 2003 22:48:36 +0000 (UTC), Erland Sommarskog
<sommar@.algonet.se> wrote:

>Ellen K. (72322.enno.esspeeayem.1016@.compuserve.com) writes:
>> So for example, the contract number field in the legacy system is 10
>> characters, but right now we're still in the 700000's so it shows up as
>> four spaces followed by six numeric characters. OPENXML eats all the
>> leading spaces (Before you ask, yes, I am enclosing each attribute in
>> quotes), so then afterwards I have to reinsert them with an UPDATE
>> statement if I want the systems to talk to each other.
>I would guess that is part of the XML specification, but I'm not very
>well versed in XML. However, this little snippet may help you to restore
>the spaces directly:
> create table #h (g char(10) NOT NULL)
> go
> declare @.xml nvarchar(4000), @.d int
> select @.xml = '<H><B g=" 123456"/><B g="1234567890"/></H>'
> exec sp_xml_preparedocument @.d output, @.xml
> insert #h(g)
> SELECT replicate(' ', 10 - len(g)) + g
> FROM OPENXML(@.d, '/H/B', 1) WITH (g char(10)) AS x
> exec sp_xml_removedocument @.d
> select '<' + g + '>' FROM #h
> go
> drop table #h|||Doug Baroter (qwert12345@.boxfrog.com) writes:
> But with today's network speed, it used to be 10 MBPS, nowdays
> standard 100 MBPS, in some environment, much greater than 100 MBPS;
> simultaneous 1000 INSERTs into the same table at a given second would
> seem to be rare even for a Fortune 100 company, hence, transaction
> speed improvement does not seem to be that a big deal.

Oh, there is a lot more to it that you imagine!

First of all, network delays comes in two flavours: transfer speed
and latency. Even a if powerful network can have significant latency.
To take an extreme example: for a while, at least, the fastest Internet
connection that was an option for private persons was satellite links.
They can give you great download speeds. But the latency is longer than
on a 9600 modem line. A crowded network can also have significant
latency. If you send many INSERT operations, then you make many routing
requests. And since communication is synchrounous, you have to wait
for respnnse too.

But there are also things to consider on the SQL Server side. If you
send singular INSERT statements, you really lose. Here is a case where
you win big with stored procedures; SQL Server does not have to parse
each statement, but can resue the cached plan.

> Now, a totally separate question if you don't mind, probably you've
> designed a stock trading system of your own, and I would think you've
> been quite sucessful in doing that, do you take a student or two
> occasionally?

I have not designed any stock-trading system on my own, but I work
for a company that provides such a product. (And which is really the
work of many knowledgable persons, not only me.) Currently, we do
not have any openings, I'm sorry.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Erland Sommarskog <sommar@.algonet.se> wrote in message >
> I have not designed any stock-trading system on my own, but I work
> for a company that provides such a product. (And which is really the
> work of many knowledgable persons, not only me.)
Thanks for the info. BTW, I was introduced to a CS professor who
designed such a system on his own, and the "word" goes around, he's
doing well with that and he himself indicates so as well, and implied
to help me get started with that too. Too bad, later on for some
weird reason he was offended.sql

Relational DB Model for an Engineering applicaiton

I'm not sure where to post this - but, I'm a DBA trying to do some modeling for a client developing an Engineering applciation.

There is a lot of interaction at the application layer between external systems and the database - I'm trying to find some ideas or templates of how others designing for a similar functionality did this.

THere are real-time displays for engineering equipment where the database must interact with different states of the equipment. The user enters search criteria for data stored in the database, and results and real-time attributes are displayed.

THis seems to be similar to a manufacturing model, but I'm struggling. I'm used to doing models for OLTP or business reporting databases. Part of the problem may be that there doesn't seem to be a good way to translate relational concepts to engineers. There are a lot of requests for bit fields.

Can anyone reccomend a reference I might look at to get some ideas on how to mesh the modeling of external processes with the database? A simple flow model doesn't seem to work (either technically or as a communication tool - I'm not sure which)

If you posted this on data mining zone I think you cant do he following things according the field:

If you can track this interaction "at the application layer between external systems and the database" you ca analyze this collected data and find some commonly behaviors of your sistems. Let's think at all the customers'bill in an retail magazine:these can say what customers like to buy.

In your case you can know:

- what' happend time to time at with these interactions;

-the links between differents states of equipments and differents real-time attributes .

After finding the behaviors follow predicting future situations.

|||

We used Winform WireFrame application with a reporting component that includes reports with the engineering diagrams, the most important thing we had access to at least ten engineers who look are what we have done and make corrections. The database used only concatenated natural keys and we the developer cannot create table and columns but we have DBO permissions. This is a fortune 10 company and we were rewriting an existing application for a new project it will be a lot of work and many developers, at one time we were about 15 just writing code.

http://www.boxesandarrows.com/view/wireframe_annotations_in_visio_special_deliverable_11

Friday, March 23, 2012

Related Tags

I have a "tagged" aplication, my model is something like:
-Item-
Id_Item
Item_Name
-Tag-
Id_Tag
Tag_Name
-Item-Tag-
Id_Item
Id_Tag
I want a stored procedure that returns me all items names in a column
and in other column all tags (separated by commas)
Item_Name Item_Tags
C#Course C#, .NET, Tutorial, Programming
Can you give some advise of how to implement it?
Best Regards
Fabio CavassiniHello, Fabio
See: http://www.aspfaq.com/show.asp?id=2529
Razvan

Related Tables: Help Needed With JOIN Query

Hi Group,

My apologies for the lengthy post, but here goes...

I have the following tables:

TABLE Vehicles
(
[ID] nvarchar(5),
[Make] nvarchar(20),
[Model] nvarchar(20),
)

TABLE [Vehicle Status]
(
[ID] int, /* this is an auto-incrementing field*/
[Vehicle ID] nvarchar(5), /* foriegn key, references Vehicles.[ID] */
[Status] nvarchar(20),
[Status Date] datetime
)

Here's my problem...

I have the following data in my [Vehicles] and [Vehicle Status] tables:

[ID] [Make] [Model]
-------
H80 Nissan Skyline
H86 Toyota Aristo

[ID] [Vehicle ID] [Status] [Status Date]
------------
1 H80 OK 2006-10-01
2 H80 Damage 2006-10-05
3 H86 OK 2006-10-13
4 H86 Dent 2006-10-15
5 H86 Scratched 2006-10-16

I need a query that will join the two tables so that the most recent
status of each vehicle can be determined. I've gotten as far as:

SELECT Vehicle.[ID], Make, Model, [Status], [Status Date] FROM
[Vehicles] INNER JOIN [Vehicle Status] ON [Vehicles].[ID] = [Vehicle
Status].[Vehicle ID]

Of course this produces the following results:

[ID] [Make] [Model] [Status] [Status Date]
--------------
H80 Nissan Skyline OK 2006-10-01
H80 Nissan Skyline Damage 2006-10-05
H86 Toyota Aristo OK 2006-10-13
H86 Toyota Aristo Dent 2006-10-15
H86 Toyota Aristo Scratched 2006-10-16

How do I filter these results so that I get only the MOST RECENT vehicle
status?

i.e:

[ID] [Make] [Model] [Status] [Status Date]
--------------
H80 Nissan Skyline Damage 2006-10-05
H86 Toyota Aristo Scratched 2006-10-16

Thanks in advance,
Rommel the iCeMAn

*** Sent via Developersdex http://www.developersdex.com ***SELECT v.[ID], Make, Model, [Status], [Status Date]
FROM
[Vehicles] v INNER JOIN [Vehicle Status] vs ON v.[ID] = vs.[Vehicle ID]
and vs.[Status Date] = (select max(vs2.[Status Date]) from [Vehicle
Status] vs2 where vs2.[Vehicle ID] = vs.[Vehicle ID])

www.nigelrivett.net
*** Sent via Developersdex http://www.developersdex.com ***sql

Related Tables in Model Files

I want to create a model file that relates two tables. However, these tables do not have a foreign key relationship in the database. Is there any way to do this? I'm hoping to programmatically generate the XML for the smdl file. Here's the XML that is generated when there is a foreign key:

<Role ID="G958db767-3d65-4445-9ccb-5f76c41720fb">

<Name>Linked Problem</Name>

<RelatedRoleID>Gf5496c9e-13b8-4c66-965d-c3a3c9a78cc8</RelatedRoleID>

<Cardinality>OptionalOne</Cardinality>

<Relation Name="dbo_Incident_FK_Incident_Problem" RelationEnd="Target" />

</Role>

Is there any way to change this to XML reference a table and join fields instead of a FK?

The Role in the report model must be bound to a Relation in the Data Source View (DSV), but the Relation does not need to have any corresponding FK constraint in the underlying database. The solution is to define the Relation you want in the DSV section of the file, then create the Role pair and bind them to it.

|||Hi Bob,

To form the relation, I assume you mean that I make a key/keyref pair in the schema. Is this correct?

As for the role pair, I don't understand exactly where these items go. I looked at the ones generated when there was a FK in the database. It looks like one goes at the end of the first table's attribute (field) list and the second one replaces the attribute in the second table. Is this correct?

If you have any XML samples I would really appreciate it. I tried everything I could think of today and got nothing but errors when I tried to upload the model files.

Thanks!|||Never mind. I've since discovered that you can set up a foreign key with the "NO CHECK" option. I think I can do that and save myself from having to programmatically generate SMDL. Thanks!