Showing posts with label design. Show all posts
Showing posts with label design. Show all posts

Friday, March 30, 2012

KPI design and implementation

Hi all,

I'm fairly new to analysis services and am encountering some difficulties when it comes to designing KPI's. I want these to be designed so that they may be displayed in a KPI list on Sharepoint 2007 server.

The basic premise for the simple data warehouse pilot was to present usage data for a number of customer sites split up but time etc. These sites also have a potential usage value attached to them. I'd like to implement a KPI that shows the current progress in the current month for there usage against the site's potential. A cylinder or thermometer type diagram i believe would work well to show the progress as a percentage value.

This may be to vague a description and i'm willing to elaborate further if necessary but could someone please help me understand how best to approach this?

Many thanks in advance,

Grant

Hello. First, if you have installed the SQL Server 2005 samples you will find an SSAS2005(Analysis Services) project, Adventure Works, with a lot of KPI:s in the cube editor. This is to get to know the MDX syntax for KPI:s.

To get the KPI:s to Sharepoint is not done directly. You will need a separate solution for this.

You can query and display KPI:s in Reporting Services 2005 but you will only see the values not the graphic/icons.

One option is to use Excel 2007 and construct a KPI spreadsheet report and publish it in Sharepoint. Another option is to use ProClarity Analytics platform and use their webparts for Sharepoint. Both these alternatives are not free of charge.

A third option is Microsofts Business Scorecard Server. It uses Sharepoint directly. This product and ProClarity will be included in the new Performance Point Server that will be on the market this summer.

HTH

Thomas Ivarsson

Knowledgeable yet simple book for database modelling or database design

Hi All,
Can u please suggest me some books for relational database design or
database modelling(Knowledgeable yet simple) i.e. from which we could
learn database relationships(one to many,many to one
etc....),building ER diagrams,proper usage of ER diagrams in our
database(Primary key foreign key relations),designing small
modules,relating tables and everything that relates about database
design...Coz I think database design is the crucial part of database
and we must know the design part very first before starting up with
databases....

Thanks and very grateful to all of you...

Vikas"vicky" <vikas.patil@.capgemini.comwrote in message
news:1187277493.878157.213600@.j4g2000prf.googlegro ups.com...

Quote:

Originally Posted by

Hi All,
Can u please suggest me some books for relational database design or
database modelling(Knowledgeable yet simple) i.e. from which we could
learn database relationships(one to many,many to one
etc....),building ER diagrams,proper usage of ER diagrams in our
database(Primary key foreign key relations),designing small
modules,relating tables and everything that relates about database
design...Coz I think database design is the crucial part of database
and we must know the design part very first before starting up with
databases....
>
Thanks and very grateful to all of you...
>
Vikas
>


The following is one good book that deals with data modelling specifically
from the ER perspective:
http://www.amazon.com/Modeling-Esse...n/dp/0126445516
However, the ER perspective is not the only way or necessarily the best way
to design a database. See also:
http://www.amazon.com/Information-M...l/dp/1558606726
Another book I highly recommend is the following. It's not a comprehensive
reference or tutorial but it does give excellent analysis and guidance on
some of the key topics.
http://www.amazon.co.uk/Practical-I...n/dp/0201485559
--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/...US,SQL.90).aspx
--|||On Aug 16, 10:18 am, vicky <vikas.pa...@.capgemini.comwrote:

Quote:

Originally Posted by

Hi All,
Can u please suggest me some books for relational database design or
database modelling(Knowledgeable yet simple) i.e. from which we could
learn database relationships(one to many,many to one
etc....),building ER diagrams,proper usage of ER diagrams in our
database(Primary key foreign key relations),designing small
modules,relating tables and everything that relates about database
design...Coz I think database design is the crucial part of database
and we must know the design part very first before starting up with
databases....
>
Thanks and very grateful to all of you...
>
Vikas


Search for Louis Davidson's books on database design.

Alex Kuznetsov, SQL Server MVP
http://sqlserver-tips.blogspot.com/|||On Aug 17, 2:04 am, Alex Kuznetsov <AK_TIREDOFS...@.hotmail.COMwrote:

Quote:

Originally Posted by

On Aug 16, 10:18 am, vicky <vikas.pa...@.capgemini.comwrote:
>

Quote:

Originally Posted by

Hi All,
Can u please suggest me some books for relationaldatabasedesignor
databasemodelling(Knowledgeableyetsimple) i.e. from which we could
learndatabaserelationships(one to many,many to one
etc....),building ER diagrams,proper usage of ER diagrams in our
database(Primary key foreign key relations),designing small
modules,relating tables and everything that relates aboutdatabase
design...Coz I thinkdatabasedesignis the crucial part ofdatabase
and we must know thedesignpart very first before starting up with
databases....


>

Quote:

Originally Posted by

Thanks and very grateful to all of you...


>

Quote:

Originally Posted by

Vikas


>
Search for Louis Davidson's books ondatabasedesign.
>
Alex Kuznetsov, SQL Server MVPhttp://sqlserver-tips.blogspot.com/


David and Alex Thank you very much...

Monday, March 19, 2012

Key/Index Questions

I have some simple questions about database design in MSSQL2005. My background
is primarily writing code, but I do understand databases, however I'm (fairly)
new to MSSQL.
My database is to be a single primary table (we`ll call it P) with other tables
(say, about 10-15) being related like this: P <-->> X
Every table has an Identity column which is also the defined Primary Key for
that table.
It's possible that Table P could have up to a million rows, and each Table X
could have up to between 3-10 rows each related to a single row in Table P.
It's a simple database really, but could get large in scope.
My question has to do with Keys and Indexes on these tables, and I guess I'm
having difficulty (in MSSQL terms) understanding what is a "rule" of the
database and what is a "part" of the database. I'm confused when declaring a
KEY (CONSTRAINT) - does that actually creates a "key/index"?
It seems when I declare a Primary Key constraint, then an Index gets created
automatically. But I'm not sure about declaring a Foreign Key on a child table
- does that create an Index or not?
I also want to design it best for performance too<g>. Each and every row will
be INSERTed and/or UPDATEd individually and very few (if any) DELETES will take
place.
Do I absolutely need to specify a FOREIGN KEY on every child table? My
understanding is that if I do have a FOREGN KEY, then any UPDATE on a child row
will cause a referential check to be made on the parent...maybe causing a
performance issue if the tables were large. Will the database perform well, evn
if I do not specify Foreign Keys?
Whether or not, I specify FOREIGN KEYS on tables X, do I need INDEXes on the
columns that relate to the parent table P? I am pretty sure I do, especially if
I execute a SELECT statement like this:
SELECT columns FROM TableX where FK_Column = 'value'
Thanks BrianBrian, see inline
Brian Staff wrote:
> I have some simple questions about database design in MSSQL2005. My background
> is primarily writing code, but I do understand databases, however I'm (fairly)
> new to MSSQL.
> My database is to be a single primary table (we`ll call it P) with other tables
> (say, about 10-15) being related like this: P <-->> X
> Every table has an Identity column which is also the defined Primary Key for
> that table.
Yuck. Different people have different opinions about this. My opinion is
that an Identity column should not be added out of convention. IMO, it
should be added if no other (proper) key is available, which is highly
unlikely to be the case for all your 10-15 tables...
> It's possible that Table P could have up to a million rows, and each Table X
> could have up to between 3-10 rows each related to a single row in Table P.
> It's a simple database really, but could get large in scope.
> My question has to do with Keys and Indexes on these tables, and I guess I'm
> having difficulty (in MSSQL terms) understanding what is a "rule" of the
> database and what is a "part" of the database. I'm confused when declaring a
> KEY (CONSTRAINT) - does that actually creates a "key/index"?
A "rule" is a type of generic check constraint that can be tagged to any
table. Rules are deprecated and in my experience nobody uses them
(because they are a hassle). Best to forget about them.
I have no idea what "part" refers to. I don't think there is an MSSQL
concept called "part".
> It seems when I declare a Primary Key constraint, then an Index gets created
> automatically. But I'm not sure about declaring a Foreign Key on a child table
> - does that create an Index or not?
Only a Primary Key constraint and a Unique constraint will automatically
create a corresponding (unique) index. If you want your Foreign Key
indexed, then you have to add such an index yourself.
> I also want to design it best for performance too<g>. Each and every row will
> be INSERTed and/or UPDATEd individually and very few (if any) DELETES will take
> place.
> Do I absolutely need to specify a FOREIGN KEY on every child table?
I don't know. If you want to ensure data integrity, then you need it. If
you don't care, or think all data modifications will be done through
your application, and you handle the data integrity in your application,
then you can choose to omit the foreign key constraint - at your own
risk.
> My
> understanding is that if I do have a FOREGN KEY, then any UPDATE on a child row
> will cause a referential check to be made on the parent...
Correct.
> maybe causing a performance issue if the tables were large.
Possible, but unlikely. Although you will see more reads (and therefore
potential I/O) and more locking/blocking.
> Will the database perform well, evn if I do not specify Foreign Keys?
Foreign Keys are not primarily for performance. In most cases they don't
help SELECT performance, but they never hinder either. They mostly
affect the performance of data modifications (negatively).
> Whether or not, I specify FOREIGN KEYS on tables X, do I need INDEXes on the
> columns that relate to the parent table P? I am pretty sure I do, especially if
> I execute a SELECT statement like this:
> SELECT columns FROM TableX where FK_Column = 'value'
If this FK_Column is not the first column of the Primary Key, then such
a query would definitely benefit from an index.
Also, such an index helps if you have the Foreign Key in place, and you
delete a row from the referenced table (in your case table P).
HTH,
Gert-Jan
> Thanks Brian
>|||Nice reply Gert-Jan, after reading yours, I deleted mine.
One note: DOUBLE & TRIPLE YUCK on making all PK's IDENTITY.
Besides what Gert-Jan said (which I agree with), if you ever decide to use
Distributed Partition Views across multiple nodes of a cluster, you won't be
able to select all relevant data in a select from a single server - and
performance will suck.
The only time I even consider IDENTITY for a PK on something other than a
parent table is when I'm getting into many part compound PK's - and even
then I look real hard for something better.
Jay
PS. Sorry, pet peeve.
"Gert-Jan Strik" <sorry@.toomuchspamalready.nl> wrote in message
news:46C9ECDD.A2606551@.toomuchspamalready.nl...
> Brian, see inline
> Brian Staff wrote:
>> I have some simple questions about database design in MSSQL2005. My
>> background
>> is primarily writing code, but I do understand databases, however I'm
>> (fairly)
>> new to MSSQL.
>> My database is to be a single primary table (we`ll call it P) with other
>> tables
>> (say, about 10-15) being related like this: P <-->> X
>> Every table has an Identity column which is also the defined Primary Key
>> for
>> that table.
> Yuck. Different people have different opinions about this. My opinion is
> that an Identity column should not be added out of convention. IMO, it
> should be added if no other (proper) key is available, which is highly
> unlikely to be the case for all your 10-15 tables...
>> It's possible that Table P could have up to a million rows, and each
>> Table X
>> could have up to between 3-10 rows each related to a single row in Table
>> P.
>> It's a simple database really, but could get large in scope.
>> My question has to do with Keys and Indexes on these tables, and I guess
>> I'm
>> having difficulty (in MSSQL terms) understanding what is a "rule" of the
>> database and what is a "part" of the database. I'm confused when
>> declaring a
>> KEY (CONSTRAINT) - does that actually creates a "key/index"?
> A "rule" is a type of generic check constraint that can be tagged to any
> table. Rules are deprecated and in my experience nobody uses them
> (because they are a hassle). Best to forget about them.
> I have no idea what "part" refers to. I don't think there is an MSSQL
> concept called "part".
>> It seems when I declare a Primary Key constraint, then an Index gets
>> created
>> automatically. But I'm not sure about declaring a Foreign Key on a child
>> table
>> - does that create an Index or not?
> Only a Primary Key constraint and a Unique constraint will automatically
> create a corresponding (unique) index. If you want your Foreign Key
> indexed, then you have to add such an index yourself.
>> I also want to design it best for performance too<g>. Each and every row
>> will
>> be INSERTed and/or UPDATEd individually and very few (if any) DELETES
>> will take
>> place.
>> Do I absolutely need to specify a FOREIGN KEY on every child table?
> I don't know. If you want to ensure data integrity, then you need it. If
> you don't care, or think all data modifications will be done through
> your application, and you handle the data integrity in your application,
> then you can choose to omit the foreign key constraint - at your own
> risk.
>> My
>> understanding is that if I do have a FOREGN KEY, then any UPDATE on a
>> child row
>> will cause a referential check to be made on the parent...
> Correct.
>> maybe causing a performance issue if the tables were large.
> Possible, but unlikely. Although you will see more reads (and therefore
> potential I/O) and more locking/blocking.
>> Will the database perform well, evn if I do not specify Foreign Keys?
> Foreign Keys are not primarily for performance. In most cases they don't
> help SELECT performance, but they never hinder either. They mostly
> affect the performance of data modifications (negatively).
>> Whether or not, I specify FOREIGN KEYS on tables X, do I need INDEXes on
>> the
>> columns that relate to the parent table P? I am pretty sure I do,
>> especially if
>> I execute a SELECT statement like this:
>> SELECT columns FROM TableX where FK_Column = 'value'
> If this FK_Column is not the first column of the Primary Key, then such
> a query would definitely benefit from an index.
> Also, such an index helps if you have the Foreign Key in place, and you
> delete a row from the referenced table (in your case table P).
> HTH,
> Gert-Jan
>> Thanks Brian|||> Yuck. Different people have different opinions about this. My opinion is
> that an Identity column should not be added out of convention. IMO, it
> should be added if no other (proper) key is available, which is highly
> unlikely to be the case for all your 10-15 tables...
Hmmm! I see your YUCK was "raised"...twice by Jay
That's taken the wind out of my sails. I thought I was doing well in my design
especially with that part<g>. My theory on Primary Keys is that they should be
preferably be one column and numeric, since searching by alpha and/or multiple
columns would undoubtedly be slower.
Obviously a PK needs to be unique, so I'll re-examine all of the child tables
again, but I have to say that advice does not sit well with my understanding of how
databases work. One question...why is having the identity column be the PK such a
bad idea? - apart from just "yuck!"
BTW - thanks on all of the other advice - that helps a lot.
Brian|||Brian Staff wrote:
> > Yuck. Different people have different opinions about this. My opinion is
> > that an Identity column should not be added out of convention. IMO, it
> > should be added if no other (proper) key is available, which is highly
> > unlikely to be the case for all your 10-15 tables...
> Hmmm! I see your YUCK was "raised"...twice by Jay
> That's taken the wind out of my sails. I thought I was doing well in my design
> especially with that part<g>. My theory on Primary Keys is that they should be
> preferably be one column and numeric, since searching by alpha and/or multiple
> columns would undoubtedly be slower.
> Obviously a PK needs to be unique, so I'll re-examine all of the child tables
> again, but I have to say that advice does not sit well with my understanding of how
> databases work. One question...why is having the identity column be the PK such a
> bad idea? - apart from just "yuck!"
> BTW - thanks on all of the other advice - that helps a lot.
> Brian
There are reasons why many (including me) prefer a natural key over a
surrogate key. IMO, an Identity is a good choice for a surrogate key. If
you google natural vs surrogate key you will probably find a whole lot
of information on that debate.
So I am not saying that having an Identity column as the Primary Key is
not bad per se. However, a table with a foreign key very often has the
meaning of a relation table. If you take the classic example of the
table that describes which book was written by which author. This table
would have a foreign key to the Authors table, and a foreign key to the
Books table. You want the combination of author-book to be unique, so
what simpler choice that to make (author, book) the primary key of this
table? No need to add a surrogate key, very useful index on the primary
key, no need to add another constraint to make the combination
author-book unique, etc.
Now you might argue that in the example above, the primary key of the
BookAuthors table might have been an Identity column and that that key
is narrower and therefore better for performance. But in practice that
is not the case. Because you would join to this table most of the time
(or rather: almost all of the time), and the join requires access to
either/both column author_id and/or book_id. In this example, the
Identity primary key would only perform better if you were to query the
exact Primary Key value.
So if you are going to join a lot of your 10-15 tables to your table P,
then the choice of your primary key and/or the indexes on your foreign
keys is very important.
Gert-Jan|||Gert-Jan,
Thanks for your explanation. I will look carefully at my table data and
re-evaluate the PK choice.
Brian|||> There are reasons why many (including me) prefer a natural key over a
> surrogate key. IMO, an Identity is a good choice for a surrogate key. If
> you google natural vs surrogate key you will probably find a whole lot
> of information on that debate.
> So I am not saying that having an Identity column as the Primary Key is
> not bad per se. However, a table with a foreign key very often has the
> meaning of a relation table. If you take the classic example of the
> table that describes which book was written by which author. This table
> would have a foreign key to the Authors table, and a foreign key to the
> Books table. You want the combination of author-book to be unique, so
> what simpler choice that to make (author, book) the primary key of this
> table? No need to add a surrogate key, very useful index on the primary
> key, no need to add another constraint to make the combination
> author-book unique, etc.
> Now you might argue that in the example above, the primary key of the
> BookAuthors table might have been an Identity column and that that key
> is narrower and therefore better for performance. But in practice that
> is not the case. Because you would join to this table most of the time
> (or rather: almost all of the time), and the join requires access to
> either/both column author_id and/or book_id. In this example, the
> Identity primary key would only perform better if you were to query the
> exact Primary Key value.
> So if you are going to join a lot of your 10-15 tables to your table P,
> then the choice of your primary key and/or the indexes on your foreign
> keys is very important.
> Gert-Jan
My primary objection is that an IDENTITY PK usually does not describe the
data in the column, that function is taken up by indexes and non-identifying
FK's. In Gert-Jan's example a row in BookAuthors is described by the
combination of book_id and author_id, not some arbitrary IDENTITY column.
This BTW, is in large part, the definition of 3NF.
For a good description on database normilaztion:
http://www.datamodel.org/NormalizationRules.html
Jay|||This model that I was working on, as well as another one that I work
on daily, are the reasons that I have come to be wary of the surrogate
key.
create table dbo.items (
item_num varchar(16) not null,
item_desc varchar(32) not null,
constraint pk_items
primary key(item_num),
constraint u_nc_item_desc
unique(item_desc))
create table dbo.customers (
cust_name varchar(32) not null,
constraint pk_customers
primary key(cust_name))
create table dbo.cust_items (
cust_item_num varchar(16) not null,
cust_name varchar(32) not null,
constraint pk_cust_items
primary key(cust_item_num, cust_name),
constraint fk_cust_items_customers
foreign key(cust_name)
references customers(cust_name)
on update cascade)
create table dbo.cust_item_cross_ref (
cust_item_num varchar(16) not null,
cust_name varchar(32) not null,
item_num varchar(16) not null,
constraint pk_cust_item_cross_ref
primary key(cust_name, cust_item_num),
constraint u_nc_item_customer
unique(cust_name, item_num),
constraint fk_cust_item_cross_ref_items
foreign key(item_num)
references dbo.items(item_num)
on update cascade,
constraint fk_cust_item_cross_ref_cust_items
foreign key(cust_item_num, cust_name)
references dbo.cust_items(cust_item_num, cust_name)
on update cascade)
The cust_item_cross_ref table was the source of my difficulty.
The business rules surrounding this table are simply this:
1. Each of our items can be referenced by a customer once.
- covered by u_nc_item_customer
2. Each customer_item can be referenced once.
- covered by pk_cust_item_cross_ref
3. Each item can be referenced to multiple customer_items
If I had used a surrogate key in the cust_items table then I would
have a very interesting time in trying to enforce my business rules at
the cross_ref table. Example below:
create table dbo.cust_items_id (
cust_item_id int identity(1,1),
cust_item_num varchar(16) not null,
cust_name varchar(32) not null,
constraint pk_cust_items
primary key (cust_item_id),
constraint nk_cust_items
primary key(cust_item_num, cust_name),
constraint fk_cust_items_customers
foreign key(cust_name)
references dbo.customers(cust_name)
on update cascade)
create table dbo.cust_item_cross_ref_id (
cust_item_id int not null,
item_num varchar(16) not null,
constraint pk_cust_item_cross_ref
primary key(cust_item_id),
constraint fk_cust_item_cross_ref_items
foreign key(item_num)
references dbo.items(item_num)
on update cascade,
constraint fk_cust_item_cross_ref_cust_items
foreign key(cust_item_id)
references dbo.cust_items(cust_item_id)
on update cascade)
This does not allow me to enforce my second requirement. See the
sample data.
insert into items (item_num, item_desc) values ('Item A', 'Item A')
insert into items (item_num, item_desc) values ('Item B', 'Item B')
insert into customers (cust_name) values ('Cust A')
insert into cust_items (cust_item_num, cust_name) values ('AA', 'Cust
A')
insert into cust_items (cust_item_num, cust_name) values ('AB', 'Cust
A')
insert into cust_items_id (cust_item_num, cust_name) values ('AA',
'Cust A') -- id = 1
insert into cust_items_id (cust_item_num, cust_name) values ('AB',
'Cust A') -- id = 2
In this example I have two items and one customer who has two items.
Both methods prevent me from assigning a customer item to two of my
items. That rule is well enforced. However, in the surrogate key
method, I cannot enforce the other rule. I can freely assign 'Item A'
to cust_id = 1 and to cust_id = 2.
The method that I came up with to solve the problem was either a
trigger (bad...) or to create an indexed view.
create view dbo.bandaid_view with schemabinding
as
select
ci.cust_name,
cr.item_num
from
dbo.cust_item_cross_ref_id as cr
inner join dbo.cust_items_id as ci
on cr.cust_item_id = ci.cust_item_id
go
create unique clustered index u_bandaid on dbo.bandaid_view(cust_name,
item_num)
That solution worked, and would could be used in future. Since I'm
not sold on the performance issue of natural keys vs surrogate keys,
I'll have to stick with the natural keys for now. That may change in
the future, but it will stay this way for now.
Cheers,
Jason Lepack
On Aug 20, 9:34 pm, "JayKon" <s...@.nospam.org> wrote:
> > There are reasons why many (including me) prefer a natural key over a
> > surrogate key. IMO, an Identity is a good choice for a surrogate key. If
> > you google natural vs surrogate key you will probably find a whole lot
> > of information on that debate.
> > So I am not saying that having an Identity column as the Primary Key is
> > not bad per se. However, a table with a foreign key very often has the
> > meaning of a relation table. If you take the classic example of the
> > table that describes which book was written by which author. This table
> > would have a foreign key to the Authors table, and a foreign key to the
> > Books table. You want the combination of author-book to be unique, so
> > what simpler choice that to make (author, book) the primary key of this
> > table? No need to add a surrogate key, very useful index on the primary
> > key, no need to add another constraint to make the combination
> > author-book unique, etc.
> > Now you might argue that in the example above, the primary key of the
> > BookAuthors table might have been an Identity column and that that key
> > is narrower and therefore better for performance. But in practice that
> > is not the case. Because you would join to this table most of the time
> > (or rather: almost all of the time), and the join requires access to
> > either/both column author_id and/or book_id. In this example, the
> > Identity primary key would only perform better if you were to query the
> > exact Primary Key value.
> > So if you are going to join a lot of your 10-15 tables to your table P,
> > then the choice of your primary key and/or the indexes on your foreign
> > keys is very important.
> > Gert-Jan
> My primary objection is that an IDENTITY PK usually does not describe the
> data in the column, that function is taken up by indexes and non-identifying
> FK's. In Gert-Jan's example a row in BookAuthors is described by the
> combination of book_id and author_id, not some arbitrary IDENTITY column.
> This BTW, is in large part, the definition of 3NF.
> For a good description on database normilaztion:
> http://www.datamodel.org/NormalizationRules.html
> Jay- Hide quoted text -
> - Show quoted text -

Friday, March 9, 2012

keeping track of modification date of a row

timestamp type seems to be the design to keep tracking of the modification
date (at least it's convertible to datetime) of a row; but is there a better
way to keep track it with a datetime type? I hope to avoid doing the
conversion everytime I need to look at the data (many rows at a time.)
Creating trigger is obviously possible but I hope for something simpler.
thanks!
TIMESTAMP has absolutely nothing to do with date or time! Can you show how
you are converting it to a datetime value, and demonstrate a case where
TIMESTAMP is accurately tracking the last date/time a row was updated?
Use a LastUpdatedDate column and update it with a trigger or, if you control
access to the table via stored procedures, you can use the stored procedure
to include an update to that column whenever any other value in the row is
touched.
"Zester" <zeze@.nottospam.com> wrote in message
news:eteRVyfWIHA.5716@.TK2MSFTNGP05.phx.gbl...
> timestamp type seems to be the design to keep tracking of the modification
> date (at least it's convertible to datetime) of a row; but is there a
> better way to keep track it with a datetime type? I hope to avoid doing
> the conversion everytime I need to look at the data (many rows at a time.)
> Creating trigger is obviously possible but I hope for something simpler.
> thanks!
>
|||Hi Zester,
If you are working either with SQL Server 2000 or 2005, you have no other
chance than triggers.
But if you can wait until SQL Server 2008 arrives, things will be different.
You will have tracking features included on the server, along with two new
datatypes: DATE and TIME. (Separated at last!!!)
Hope this would be helpful. Please, rate this post. Thanks!
May the bytes be with you!!!
Pedro López-Belmonte Eraso
MCAD, MCT
"Zester" wrote:

> timestamp type seems to be the design to keep tracking of the modification
> date (at least it's convertible to datetime) of a row; but is there a better
> way to keep track it with a datetime type? I hope to avoid doing the
> conversion everytime I need to look at the data (many rows at a time.)
> Creating trigger is obviously possible but I hope for something simpler.
> thanks!
>
>

keeping track of modification date of a row

timestamp type seems to be the design to keep tracking of the modification
date (at least it's convertible to datetime) of a row; but is there a better
way to keep track it with a datetime type? I hope to avoid doing the
conversion everytime I need to look at the data (many rows at a time.)
Creating trigger is obviously possible but I hope for something simpler.
thanks!TIMESTAMP has absolutely nothing to do with date or time! Can you show how
you are converting it to a datetime value, and demonstrate a case where
TIMESTAMP is accurately tracking the last date/time a row was updated?
Use a LastUpdatedDate column and update it with a trigger or, if you control
access to the table via stored procedures, you can use the stored procedure
to include an update to that column whenever any other value in the row is
touched.
"Zester" <zeze@.nottospam.com> wrote in message
news:eteRVyfWIHA.5716@.TK2MSFTNGP05.phx.gbl...
> timestamp type seems to be the design to keep tracking of the modification
> date (at least it's convertible to datetime) of a row; but is there a
> better way to keep track it with a datetime type? I hope to avoid doing
> the conversion everytime I need to look at the data (many rows at a time.)
> Creating trigger is obviously possible but I hope for something simpler.
> thanks!
>|||Hi Zester,
If you are working either with SQL Server 2000 or 2005, you have no other
chance than triggers.
But if you can wait until SQL Server 2008 arrives, things will be different.
You will have tracking features included on the server, along with two new
datatypes: DATE and TIME. (Separated at last!!!)
Hope this would be helpful. Please, rate this post. Thanks!
--
May the bytes be with you!!!
Pedro López-Belmonte Eraso
MCAD, MCT
"Zester" wrote:
> timestamp type seems to be the design to keep tracking of the modification
> date (at least it's convertible to datetime) of a row; but is there a better
> way to keep track it with a datetime type? I hope to avoid doing the
> conversion everytime I need to look at the data (many rows at a time.)
> Creating trigger is obviously possible but I hope for something simpler.
> thanks!
>
>

Keeping relational design with XML

I'm trying to prove or disprove whether or not it is best
to keep a relational db structure and use the built in
functionality for XML. I have a developer who want to
just plop the entire XML string into a single column. I
can prove the performance, but I'm hoping to find some
documentation to back myself up and don't really find any
reference to the fact that the schema of the database
should still be designed relationally. Does that make
any sense, can anyone help, do you know of any resources?
Please and Thanks,
Rachel
Start here:
http://www.oceaninformatics.biz/publications/e2.pdf
http://www.dbazine.com/pascal4.html
http://searchdatabase.techtarget.com...511729,00.html
"Rachel" <anonymous@.discussions.microsoft.com> wrote in message
news:168f01c4ad46$faa638d0$a301280a@.phx.gbl...
> I'm trying to prove or disprove whether or not it is best
> to keep a relational db structure and use the built in
> functionality for XML. I have a developer who want to
> just plop the entire XML string into a single column. I
> can prove the performance, but I'm hoping to find some
> documentation to back myself up and don't really find any
> reference to the fact that the schema of the database
> should still be designed relationally. Does that make
> any sense, can anyone help, do you know of any resources?
> Please and Thanks,
> Rachel
>
|||Hmm. The first paper is mainly arguing that you should not expect XML to
help you solve semantic heterogeneity. Well, that is fine, but neither does
the relational model. And the paper does not address the question asked.
The second and third articles are nitpick articles by Fabian Pascal who has
his own way of looking at things and again, do not give a good reply to the
question asked (except for adding FUD and "proof by authority").
The third one needs registration.
To give you a more constructive answer, consider the following:
1. How is the data represented in the programming layer? Objects, XML
documents, individual information, DataSet?
2. What do you want to do with the data, once it is in the database? Do you
want to query it, repurpose it (ie, the XML has customer elements containing
order elements but you may want to run reports only over orders), update it
at a property level? If so, you probably want to shred it into relational
form (assuming that you can extract the information that way) and use XML
publishing functionality (in SQL Server 2000 look at OpenXML, FOR XML or
annotated schema).
If you mainly want to store the XML and retrieve it as such (basically cache
it to disk), the storing it as XML if it was already XML in the program
layer seems like a good idea.
3. Does the XML represent hierarchical relational data or document markup,
where order is important?
For some of that, feel free to take a look at my TechEd presentation on XML
that contains a slide about when to go relational and not XML and when to
consider tradeoffs. You can find it from on my Blog at
http://sqljunkies.com/weblog/mrys
Best regards
Michael
"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:eW0UeeUrEHA.2244@.TK2MSFTNGP15.phx.gbl...
> Start here:
> http://www.oceaninformatics.biz/publications/e2.pdf
> http://www.dbazine.com/pascal4.html
> http://searchdatabase.techtarget.com...511729,00.html
> "Rachel" <anonymous@.discussions.microsoft.com> wrote in message
> news:168f01c4ad46$faa638d0$a301280a@.phx.gbl...
>
|||"Michael Rys [MSFT]" <mrys@.online.microsoft.com> wrote in message
news:%23zaIqpZrEHA.1952@.TK2MSFTNGP12.phx.gbl...
> Hmm. The first paper is mainly arguing that you should not expect XML to
> help you solve semantic heterogeneity. Well, that is fine, but neither
does
> the relational model. And the paper does not address the question asked.
The first paper was posted because the most common argument I hear from
people who want to store their data in XML form rather than relational form
is that it facilitates rapid development by allowing software engineers to
use XML parsers rather than loop through recordsets and allows them to
"look" at the data in order to debug issues more quickly. This paper points
out some of the problems with the latter argument.

> The second and third articles are nitpick articles by Fabian Pascal who
has
> his own way of looking at things and again, do not give a good reply to
the
> question asked (except for adding FUD and "proof by authority").
Why do they not give a good reply? They very clearly state issues with
storing data in XML format. Some of the arguments, whcih I find to be
compelling:
XML lacks a formal data model and query algebra. XML is rigidly
hierarchical. XML does not provide data integrity features. (see second
article)
And there is a good reason for all of this: XML is not designed for
data management. XML is designed for document management, an entirely
different field. (see third article)

> To give you a more constructive answer, consider the following:
> 1. How is the data represented in the programming layer? Objects, XML
> documents, individual information, DataSet?
This generally has little bearing on how the data should be stored in
the database. Storing data based on how it's represented in application
code creates a tight coupling between the two that defeats the ideas of
application agnostic databases and encapsulation of the data model by the
DBMS. This can create huge problems when it comes time to create new
applications that use the same data. There are good reasons that we moved
from embedding SQL in the application to using stored procedures.

> If you mainly want to store the XML and retrieve it as such (basically
cache
> it to disk), the storing it as XML if it was already XML in the program
> layer seems like a good idea.
I agree with this, but only to a point. I have seen too many projects
where the original scope, "we will not query this XML", was later changed
to, "we need to query some of this XML". A great deal of pain would have
been avoided by storing the data relationally from the beginning.
|||Michael,
Can you please provide a brief description of, perhaps with an example, what
semantic heterogeneity is?
I assume it means some kind of miscommunication of meanings. BTW, I did some
googling, the term is being used extensively by the research community, but
could not find a meaningful definition in the context of databases.
Anith
|||See below.
Best regards
Michael
"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:e1hpVttrEHA.3896@.TK2MSFTNGP15.phx.gbl...
> "Michael Rys [MSFT]" <mrys@.online.microsoft.com> wrote in message
> news:%23zaIqpZrEHA.1952@.TK2MSFTNGP12.phx.gbl...
> does
> The first paper was posted because the most common argument I hear from
> people who want to store their data in XML form rather than relational
> form
> is that it facilitates rapid development by allowing software engineers to
> use XML parsers rather than loop through recordsets and allows them to
> "look" at the data in order to debug issues more quickly. This paper
> points
> out some of the problems with the latter argument.
> has
> the
> Why do they not give a good reply? They very clearly state issues with
> storing data in XML format. Some of the arguments, whcih I find to be
> compelling:
> XML lacks a formal data model and query algebra. XML is rigidly
> hierarchical. XML does not provide data integrity features. (see second
> article)
The formal data model and query algebra is what the XQuery WG is working on
(currently in Last Call). And there are more research papers on alternative
data models and query algebras since at least 1998 (I am author of at least
two).
So claiming that such a thing does not exist is - let's say - either
ignorant or worse.
Data integrity features exist with DTD and XML Schema. However they do not
follow the relation FK-PK model. And that relational database systems (or to
use Fabian's "term" SQL database systems) do not yet provide a direct FK-PK
mechanism between a relational field and some XML element/attribute has more
to do with the product-cycles not having progressed that far than any
theoretical problem.

> And there is a good reason for all of this: XML is not designed for
> data management. XML is designed for document management, an entirely
> different field. (see third article)
Well, document management also needs formal data models and algebras.
Especially if you start using XML as a tree model to describe semistructured
data (see Lore and UnQL for some pre-XML semistructured data models).

> This generally has little bearing on how the data should be stored in
> the database. Storing data based on how it's represented in application
> code creates a tight coupling between the two that defeats the ideas of
> application agnostic databases and encapsulation of the data model by the
> DBMS. This can create huge problems when it comes time to create new
> applications that use the same data. There are good reasons that we moved
> from embedding SQL in the application to using stored procedures.
Actually, if the data is not represented in XML then you probably should ask
yourself twice whether you want to store it as such. So therefore there is a
very good reason to ask this question. Also, if the data indeed is an XML
_document_ then knowing that in order to know how to store it is also
important (since the general shredding does not work).

> cache
> I agree with this, but only to a point. I have seen too many projects
> where the original scope, "we will not query this XML", was later changed
> to, "we need to query some of this XML". A great deal of pain would have
> been avoided by storing the data relationally from the beginning.
If it fits. Often it may not. And that's where the XQuery support in SQL
Server 2005 comes to play.
Best regards
Michael
>
|||This is a category of problems associated with different parties (companies,
applications etc.) using terms that are semantically related but different
or semantically not related but the same. This miscommunication of meaning
is what makes interoperability between different database schemata or
database and application schema more difficult. It is often used as a
counter-argument to the claim that XML helps interop. The point is that the
issue is not specific to XML. XML has other benefits in interop (can
represent hierarchies which CSV cannot, parsers are widely available, is
based on Unicode (thus international)) but does not address this.
Best regards
Michael
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:%235Ld4TzrEHA.3980@.TK2MSFTNGP12.phx.gbl...
> Michael,
> Can you please provide a brief description of, perhaps with an example,
> what semantic heterogeneity is?
> I assume it means some kind of miscommunication of meanings. BTW, I did
> some googling, the term is being used extensively by the research
> community, but could not find a meaningful definition in the context of
> databases.
> --
> Anith
>
|||Thanks for your response. Since you seem to be knowledgeable in XML related
data management issues, perhaps you could clear up some of my confusion
regarding XML's utility.
[vbcol=seagreen]
I fail to see any of the above points to be reasonable to overwhelmingly
consider XML as an alternative. Why can't we use comma separated path
enumerated strings to represent hierarchies in an ASCII file, since the
structure is always an acyclic graph? For instance, like:
Root, Level1, Level2,...Level n-2, Leaf
Regarding the availability of parsers, it is like putting the cart before
the horse. Nobody wrote XML parsers before XML's invention, right?. So
claiming that as a benefit can be moot. On the other hand, it may probably
take about a few hours for an average programmer to come up with a CSV
parser in his/her favorite programming language.
Regarding UNICODE support, how is an n-character CSV any different? Tons of
APIs are out there which could convert non-Unicode text to 16-bit encoded
Unicode & vice-versa.
[vbcol=seagreen]
Actually regarding interoperability, I was under that impression as well
till now. If that is not related to XML and if XML has its place in data
management, which specific data management problem that is not addressed in
a relational system, does XML address?
Again, thanks for your time.
Anith
|||See below.
Best regards
Michael
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:OYJk5m1rEHA.896@.TK2MSFTNGP12.phx.gbl...
> Thanks for your response. Since you seem to be knowledgeable in XML
> related data management issues, perhaps you could clear up some of my
> confusion regarding XML's utility.
>
> I fail to see any of the above points to be reasonable to overwhelmingly
> consider XML as an alternative. Why can't we use comma separated path
> enumerated strings to represent hierarchies in an ASCII file, since the
> structure is always an acyclic graph? For instance, like:
> Root, Level1, Level2,...Level n-2, Leaf
Sure you can. But you will have to document the format, make sure that it
can work across Windows, Unix, mainframe in different codepage encodings,
and even then nobody else will understand it or will be locked into your
format (note the wide availability of XML as the common syntax allows you to
build decoupled systems).

> Regarding the availability of parsers, it is like putting the cart before
> the horse. Nobody wrote XML parsers before XML's invention, right?. So
> claiming that as a benefit can be moot. On the other hand, it may probably
> take about a few hours for an average programmer to come up with a CSV
> parser in his/her favorite programming language.
Correct. Everyone comes up with his or her own format and you cannot use
commoditized tools. Is that really a benefit?

> Regarding UNICODE support, how is an n-character CSV any different? Tons
> of APIs are out there which could convert non-Unicode text to 16-bit
> encoded Unicode & vice-versa.
It is not the Unicode per se, but also the ability of the format to be
fairly good at communicating what encoding the document actually is in.

> Actually regarding interoperability, I was under that impression as well
> till now. If that is not related to XML and if XML has its place in data
> management, which specific data management problem that is not addressed
> in a relational system, does XML address?
Can I point you to my TechEd 2004 presentation linked from
http://sqljunkies.com/WebLog/mrys/ar.../08/2967.aspx?
In general:
- data exchange message format (for loosely coupled systems)
- document management (where you use XML as a markup format) because you can
use XQuery/XPath to query it.
- semi-structured data representation

> Again, thanks for your time.
> --
> Anith
>
|||>> Sure you can. But you will have to document the format, make sure that it[vbcol=seagreen]
In other words, if we can standardize the documentation of formats ( like
DTD, schema ), CSVs can also address the same data exchange issues.
[vbcol=seagreen]
In other words, if we can standardize the CSV, it will no longer be an
XML-specific benefit.
[vbcol=seagreen]
In other words, if we can standardize various encodings, CSV can address
this issue as well.
So it is clear that there is nothing special to XML other than it is a
well-standardized text format which is poised to be ( or already ) widely
popular. In a nutshell, one can conclude that we could have come up with any
formats or any text based structures and as long as it is standardized, it
can address the same data exchange problems that XML is intended to address.
Am I correct?
[vbcol=seagreen]
[vbcol=seagreen]
Thanks for the references. I have several questions with the points on your
presentations, but this may not be the right venue to address them.
Anith