Showing posts with label believe. Show all posts
Showing posts with label believe. Show all posts

Monday, March 19, 2012

Composite Key?

I'm just now learning both SQL and ASP.NET, and I cannot seem to figure out how to build my data structure. I believe the answer to my problem is a composite key, but I cannot seem to get it to work. Here is an example. My database is of recorded dances, with exact locations within a ballroom. I believe I need 2 tables

Table #1 - DanceTable
Columns: DanceID, Name, Description, Tags

Table #2 - StepsTable
Columns DanceID, StepID, longLocation, latLocation, Action, Description

Within my ASP.NET application I want to be able to enter data about a dance, including metadata and a series of steps. The Dance and metadata content to be stored in DanceTable, and the series of moves stored in the StepsTable. I want the steps to be IDed as 1, 2, 3, 4...x with the first step being labled 1. and I want each dance to have it's own unique ID (DanceID). Right now I'm using "ExecuteNonQuery()" to add my data to my SQL database, and when I add new steps to the StepsTable SQL just finds the largest ID within StepID and increments it by one. So my steps are labeled as:

Dance1:
Step1, Step2, Step3, Step4

Dance2:
Step5, Step 6, Step7

What I really want is (or I think what I want is) is a composite primary key.

Dance1:
Step1, Step2, Step3, Step4

Dance2:
Step1, Step2, Step3

That way the StepID is used as both a primary key and it indicates the position within the dance. I guess I could just use a standard SQL table, let SQL auto generate StepID's and then add a new column called something like "StepNumber", but it just seems goofy to be generating a stepID and never using it. With composite keys (If I understand them) each step would have a unique key as a combination of the DanceID+StepID (AKA Dance 345, steps 1-10).

I pull up data by searching for dances, and then sort by StepNumber, and those should all be unique...if I can figure out how to build them.

A composite key is just a key made from multiple fields. In your case, it would be DanceID,StepID.

Your tables look fine, although if you make the StepID an identity field, you really don't need to store the "StepNumber". It's redundant. You can derive the "StepNumber" by the number of records that have the same DanceID and a lower StepID.

This would get you the @.StepNumber-th step:

SELECT TOP 1 *

FROM ( SELECT TOP (@.StepNumber) *

FROM StepsTable

WHEREDanceID=@.DanceID

ORDER BY StepID ASC) t1

ORDER BY t1.StepID DESC

Or get them all in order with "StepNumber":

SELECT *,ROW_NUMBER() OVER (ORDER BY StepID) As StepNumber

FROM StepsTable

WHEREDanceID=@.DanceID

ORDER BY StepID

But of course there is nothing prohibiting you from including a StepNumber field (Like in case you don't always want the steps to be renumbered, or they aren't contiguious, like step 1, 3, 5 with no step 2 or 4, etc). In this case, your primary key would be StepID, and I would create a unique index/constraint on DanceID,StepNumber.

Friday, February 10, 2012

Comparison between SQL 2000 and Progress db

Hello,
I have used both, if its the Progress I'm thinking of.=20
Firstly I don't believe that there are any comparisons for=20
Progress its too niche. As a database its ok, you have all=20
the normal columns, foriegn keys relationships. From a DBA=20
point of view its a bit of a pain as you don't have the=20
tools as you do in SQL server or Oracle. A good example is=20
that we have a 1 gb production database that can only be=20
backed up once an hour, and it needs to be a total backup,=20
rather than say a transactional backup.
Transfering data from progress to Window Application is a=20
pain, mainly due to the Progress Application we use are=20
all Unix based so we have to write to a text file. There=20
is an ODBC tie into Progress but its an extra, I believe=20
that it costs =A310k +.
Progress itself is both a Database and Application=20
package, i.e. the code works seemlessly with the database.=20
The progress sql is different to T-SQL and PL-SQL so you=20
will be relearning SQL if you were to get it.=20
Finally you might want to look at recruitment, we have=20
activly been recruiting Progress programmers for some time=20
and cannot find them, as opposed to SQL Server and Oracle=20
where we can normally find someone in about three months.
Peter

>--Original Message--
>Hi
>Does anybody know of any comparisons or benchmark testing=20
done on SQL 2000
>and Progress.?
>Also does anybody have any comments on using Progress as=20
a database?
>Positive or negative.
>We are busy with a evaluation of various software=20
products, and one of the
>products use a progress database, the other 2 is oracle=20
and sql2000.
>My biggest concerns is the application using the progress=20
database, as I am
>not a progress developer, or do I have any knowledge=20
about the product.
>Can anybody give me more information, personal=20
experience, or point me to a
>web site with relevant information.
>Thank you
>
>.
>
Thanks for your post Peter.
I appreciate and value your comments.
"Peter" <anonymous@.discussions.microsoft.com> wrote in message
news:922201c43359$934a6a10$a601280a@.phx.gbl...
Hello,
I have used both, if its the Progress I'm thinking of.
Firstly I don't believe that there are any comparisons for
Progress its too niche. As a database its ok, you have all
the normal columns, foriegn keys relationships. From a DBA
point of view its a bit of a pain as you don't have the
tools as you do in SQL server or Oracle. A good example is
that we have a 1 gb production database that can only be
backed up once an hour, and it needs to be a total backup,
rather than say a transactional backup.
Transfering data from progress to Window Application is a
pain, mainly due to the Progress Application we use are
all Unix based so we have to write to a text file. There
is an ODBC tie into Progress but its an extra, I believe
that it costs 10k +.
Progress itself is both a Database and Application
package, i.e. the code works seemlessly with the database.
The progress sql is different to T-SQL and PL-SQL so you
will be relearning SQL if you were to get it.
Finally you might want to look at recruitment, we have
activly been recruiting Progress programmers for some time
and cannot find them, as opposed to SQL Server and Oracle
where we can normally find someone in about three months.
Peter

>--Original Message--
>Hi
>Does anybody know of any comparisons or benchmark testing
done on SQL 2000
>and Progress.?
>Also does anybody have any comments on using Progress as
a database?
>Positive or negative.
>We are busy with a evaluation of various software
products, and one of the
>products use a progress database, the other 2 is oracle
and sql2000.
>My biggest concerns is the application using the progress
database, as I am
>not a progress developer, or do I have any knowledge
about the product.
>Can anybody give me more information, personal
experience, or point me to a
>web site with relevant information.
>Thank you
>
>.
>

Comparison between SQL 2000 and Progress db

Hello,
I have used both, if its the Progress I'm thinking of.=20
Firstly I don't believe that there are any comparisons for=20
Progress its too niche. As a database its ok, you have all=20
the normal columns, foriegn keys relationships. From a DBA=20
point of view its a bit of a pain as you don't have the=20
tools as you do in SQL server or Oracle. A good example is=20
that we have a 1 gb production database that can only be=20
backed up once an hour, and it needs to be a total backup,=20
rather than say a transactional backup.
Transfering data from progress to Window Application is a=20
pain, mainly due to the Progress Application we use are=20
all Unix based so we have to write to a text file. There=20
is an ODBC tie into Progress but its an extra, I believe=20
that it costs =A310k +.
Progress itself is both a Database and Application=20
package, i.e. the code works seemlessly with the database.=20
The progress sql is different to T-SQL and PL-SQL so you=20
will be relearning SQL if you were to get it.=20
Finally you might want to look at recruitment, we have=20
activly been recruiting Progress programmers for some time=20
and cannot find them, as opposed to SQL Server and Oracle=20
where we can normally find someone in about three months.
Peter

>--Original Message--
>Hi
>Does anybody know of any comparisons or benchmark testing=20
done on SQL 2000
>and Progress.?
>Also does anybody have any comments on using Progress as=20
a database?
>Positive or negative.
>We are busy with a evaluation of various software=20
products, and one of the
>products use a progress database, the other 2 is oracle=20
and sql2000.
>My biggest concerns is the application using the progress=20
database, as I am
>not a progress developer, or do I have any knowledge=20
about the product.
>Can anybody give me more information, personal=20
experience, or point me to a
>web site with relevant information.
>Thank you
>
>.
>Thanks for your post Peter.
I appreciate and value your comments.
"Peter" <anonymous@.discussions.microsoft.com> wrote in message
news:922201c43359$934a6a10$a601280a@.phx.gbl...
Hello,
I have used both, if its the Progress I'm thinking of.
Firstly I don't believe that there are any comparisons for
Progress its too niche. As a database its ok, you have all
the normal columns, foriegn keys relationships. From a DBA
point of view its a bit of a pain as you don't have the
tools as you do in SQL server or Oracle. A good example is
that we have a 1 gb production database that can only be
backed up once an hour, and it needs to be a total backup,
rather than say a transactional backup.
Transfering data from progress to Window Application is a
pain, mainly due to the Progress Application we use are
all Unix based so we have to write to a text file. There
is an ODBC tie into Progress but its an extra, I believe
that it costs 10k +.
Progress itself is both a Database and Application
package, i.e. the code works seemlessly with the database.
The progress sql is different to T-SQL and PL-SQL so you
will be relearning SQL if you were to get it.
Finally you might want to look at recruitment, we have
activly been recruiting Progress programmers for some time
and cannot find them, as opposed to SQL Server and Oracle
where we can normally find someone in about three months.
Peter

>--Original Message--
>Hi
>Does anybody know of any comparisons or benchmark testing
done on SQL 2000
>and Progress.?
>Also does anybody have any comments on using Progress as
a database?
>Positive or negative.
>We are busy with a evaluation of various software
products, and one of the
>products use a progress database, the other 2 is oracle
and sql2000.
>My biggest concerns is the application using the progress
database, as I am
>not a progress developer, or do I have any knowledge
about the product.
>Can anybody give me more information, personal
experience, or point me to a
>web site with relevant information.
>Thank you
>
>.
>