|
Good Day All
i have a Table with the ID Field that was not an identity Field. This Field has not Duplicates. Now later i want to Change this numeric Field as an Identity Field like this
--STEP 7 ADD THE IDENTITY BACK IN TABLE MTM_ACTV_STAFF
ALTER TABLE [New_Jaco].[dbo].[MTM_ACTV_STAFF]
ALTER COLUMN [ID] IDENTITY(1,1)
but i get an Error that says
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'IDENTITY'.
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
A quick guess, I never script these thing I use SSMS, but don't you need a data type in the alter as well as the create.
ALTER COLUMN [ID] INT IDENTITY(1,1)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
Hi all, I have what might well be considered a stupid question but fortunately none of you are my employer or former varsity prof so I'll ask away
I've always endeavored to keep my databases normalized to the best of my ability and, for the most part, I think I'm fairly well set in that line of thinking.
At my current company though some of our databases are anything but normalized. When I challenged my boss about it he responded that it was done deliberately because it is not supposed to be a relational database. It is a DB that accepts, stores and processes transactions at quite a fierce tempo and they didn't want every INSERT or SELECT statement to have to internally cross reference lots of other tables.
Fair enough, it makes sense. But then it occurred to me that I probably don't know enough about DB design because I would never have thought of that. I would simply have designed a normalized DB because that's the way I'm programmed.
So, I turned to Wikipedia but even there I can't seem to find an awful lot of information on non-normalized DB's but that's most likely because I don't really know what search terms to use.
So my question is:
1. When should a DB be normalized and when not?
2. Can anyone point me to an online article or two that deals with the topic?
3. Am I correct in assuming that a normalized DB is called a "Relational Database"?
4. What would you call a DB like ours here that is not normalized?
|
|
|
|
|
Your boss may actually be right (I work with batch processes not transactions) because with every FK and index on a table the CRUD operation need to do the additional work to maintain the relationships. I still doubt it is a valid answer though, only a reporting database should not be normalised IMHO.
Can't help more than that and I hope you find the ammo to shoot this one down.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks, but I'm not disputing that my boss is right. I think he has a valid point so I'm not really looking for ammo to shoot his argument down I'd just like to make sure I really understand DB design and not blindly stick to normalized DBs if that's not always the best way to go.
|
|
|
|
|
Ah but I think blindly sticking to normalised databases is the correct thing to do. The only exception I have found is if you are creating a summarised table for reporting, I often include the report descriptors in the summarised table. This has gone out of fashion as we are starting to use cubes to support our reporting and they are whole different matter.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The term that you are looking for is Denormalization.
In general, databases should always be normalized to at least 3NF unless there are specific areas where performance of reading/writing is a problem. However, most modern RDBMS like Sql Server are extremely efficient at joining tables using indexes so many of the reasons for denormalization are no longer applicable.
|
|
|
|
|
Dewald wrote: 1. When should a DB be normalized and when not?
You normalize it by default, removing redundancy. Once the database becomes too slow (which is usually not due to the normalization, but lack of indexes and such) you start to optimize/de-normalize/add redundancy.
You'll waste a bit more space and gain some speed.
Dewald wrote: 2. Can anyone point me to an online article or two that deals with the topic?
The Oracle FAQ[^] also contains a link to the reverse process.
Dewald wrote: 3. Am I correct in assuming that a normalized DB is called a "Relational Database"?
The fact that there are relations between the data doesn't mean that these have been normalized.
Dewald wrote: 4. What would you call a DB like ours here that is not normalized?
That depends on what you're using it for. If it's a blob-store or a container for hashtables, then I'd say that it's an optimized datastore and I'd make sure to give credit to the optimizer.
If it's relational data that you're storing, then I'd call it an "accident waiting to happen"
I are Troll
|
|
|
|
|
|
Actually Wikipedia has a good explaination of Normalization.
http://en.wikipedia.org/wiki/Database_normalization[^]
Chris Date and Edgard Codd have written numerous books on the topic and are frequently used in Universities as the course textbook. I had to study them when I was in Graduate School.
|
|
|
|
|
|
Check the link in my reply to the post below. Hope it helps.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Dear friends,
I need to export records from sql to excel. I know how to export the whole record to excel. But my requirement is, i have to insert 10 records in sheet1 and another 10 records in sheet2 and so on.... a help or some links would be highly appriciated..... (i dont want any packages like DTS)
|
|
|
|
|
The only direct way I know how to do that with separate sheets is with ADO and COM.
|
|
|
|
|
Check this[^]. I think this should help you.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
|
A seven field composite primary key - sounds like a disaster has found somewhere to happen. This is a BAD idea, I have no knowledge of the performance issues with such a mess but the sheer cumberomeness of forever doing a 7 key join would drive me to drink.
I recommend that you insert a primary key into the central table and populate it, then turn autonumber on.
Now add the foreign key field to the other table(s) and use the 7 key horror to populate the field.
Make your relationship using these fields. You must make sure you support the change within your CRUD code.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
What are some options to replace sql dependency using sql server with multiple users? I like how sqlDependency works but without some changes to my database I can't determine what was added, modified , or deleted. So when I receive a notification I'm forced to reload the dataset and refresh. While this is not a major problem with a small dataset, as the dataset grows the time required to do this will be come unacceptable. I know one option is to continue using sqldependency and only load the data displayed for the current day on the calendar. So is there any other ways to keep data sync'd in a multiple user environment?
Thanks,
Paul
Some more information:
Application is a scheduling program
Use sqldependency for notification only
Use linq to sql for actual data retrieval
|
|
|
|
|
I'll be interested in any responses to this one, I have never worked with SQLDependancy. I insist on minimum recordset size for the UI, any more than about 500 records gets looked at severely and usually the design is changed to meet the requirement.
Where I have to load a large volume I often allow the user to make a number of changes and then reload the dataset.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
We have got hundreds of tables and SPs but no diagram. Basically we just keep on adding new tables as per requirement or delete table and there is no info.
What i want to implement now is - a whole database diagram - So what would be the best way keeping in mind that database is big if not huge.
Thank You
Andyyy
|
|
|
|
|
Which database?
With SQL, it comes as a built in feature. Is that what you are looking for?
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Yeh it's SQL - sorry i mean Diagram.
Should i just use visio and find my way out but that means going through hundreds of tables and sps and understanding them..Looks like i will never get time to sort this out unless there is quicker way which is also good.
|
|
|
|
|
If you expand the [DatabaseName] node, the first thing you will see is diagram. Although AFAIK, it will not help with stored procedures.
You can also check this[^] link. Might be of some help.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
You need to be careful with SQL diagram designer you could end up applying foreign key constraints while building a diagram. SSMS will not let you save the diagram if the data does not match the constraint, so save OFTEN, this is a good thing but you are going to be VERY frustrated chasing down the data errors.
I would use visio unless you actually want to clean up the data. Personally I would opt to clean up the database there are some enormous benefits to be gained from a well structured database.
Never underestimate the power of human stupidity
RAH
|
|
|
|