Syntax for DDL table design in MSSQLServer 2014.

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
Messages
7,822
Reaction score
13,151
Hi all, I am learning DDL ( as opposed to GUI ) table design in MSSL2014.

EDIT I am given a table printout and I want as an output the(a) DDL code that would output the given table.
Sorry, I don't have a scanner nor the original file in my PC, I have a table diagram in a piece of paper.

I have the following questions, please:

1) Is there a necessary order of attributes and constraints? Meaning, can I equally write:

Create Table 'Table Name' ( attribute1 datatype(attribute1) not null/null , attribute2 datatype(attribute2) not null/null , constraint1 ...)

than
Create Table 'Table Name' ( attribute1 datatype(attribute1) not null/null , constraint1..., attribute2 datatype(attribute2) not null/null , constraint1 ...)

2) Do I need a comma between the declaration of an attribute's properties and a constraint statement?

3)Do I need a comma to separate any two consecutive constraint statements? Or do I just write ...constraint ...
constraint... ?

4) Say I have an attribute, say, JobId, in a table 'Job' and this attribute is a Foreign Key . The constraint statement here is:

constraint [FK_Job] foreign key (JobID) references ...

Can I tell from an ERD (given graphically) which attribute is being referenced? Sometimes the attribute that is being referenced is given a different name within the entity to which the attribute is exported. Is there a way of seeing which other attribute is being referenced?
I will try to scan the ERD when I get a chance.
Thanks. Thanks.
 
Last edited:
Physics news on Phys.org
  • Like
Likes   Reactions: WWGD