Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Exir
Posting Yak Master
151 Posts |
Posted - 2009-06-20 : 07:23:10
|
| Hi I can not add new database diagram, i made my diagram and set keys and relations, but when i want to save it,an error says: can not insert the value null into colum 'diagram_id', table mydb.dbo.sysdiagram;the colums doent allow nulls. Insert fails.How should i make a diagram for my database? |
|
|
Exir
Posting Yak Master
151 Posts |
Posted - 2009-06-20 : 07:53:06
|
| This problem solved but another problem occured :(when i want to save my diagram this error comes:- Unable to create relationship 'FK_Persons_Pr_Education'. The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_Persons_Pr_Education". The conflict occurred in database "mydb", table "dbo.Pr_Education", column 'Pr_Education_code'. |
 |
|
|
Exir
Posting Yak Master
151 Posts |
Posted - 2009-06-20 : 23:50:04
|
| any solution ? |
 |
|
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2009-06-21 : 00:07:36
|
| Exir,When you click save in the diagram you are actually executing DDL statements against the db. So, the error you are getting is a result of the DDL failing on the fk relationship creation. You most likely have some data in the Persons table that does not exist in the Education table. Therefore, you cannot create a relationship between them. To be honest, I find that data modeling in the diagram editor is more trouble than it is worth. You would be better off just writing the ddl yourself. |
 |
|
|
Exir
Posting Yak Master
151 Posts |
Posted - 2009-06-21 : 00:46:28
|
| thank you nathans for your response butI was using data modeling diagram till now, i dont know how to write ddl :(, could you please guide me more? where and what should i write to make a ddl? |
 |
|
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2009-06-21 : 01:17:07
|
| For example, instead of creating a new table in the diagram tool, just use management studio to write a CREATE TABLE statement. You will need to read up if you havent used this before. Books online is a great resource: http://msdn.microsoft.com/en-us/library/ms174979.aspxYou might find some benefit to viewing the DDL script that the diagram tool creates (rather than saving the diagram as you did before). If you open a new diagram, create a new table. Then (without saving it) click on the "Generate Change Script" button on the toolbar. In that dialog you can view the script that would have been executed against your db had you saved the diagram. Dont let the wordy syntax in that dialog discourage you from learning DDL. Start simple, learn how to create a table using the CREATE TABLE statement. Then move on to learning ALTER TABLE, etc. You will never miss the diagram tool again!Nathan Skerl |
 |
|
|
Exir
Posting Yak Master
151 Posts |
Posted - 2009-06-21 : 02:27:36
|
| oh, I know how to make table,sp and other things using create or change with alter but i dont know how to make relationship between them, anyways i hope i can learn it by reading the link you sent.thank you |
 |
|
|
|
|
|
|
|