Syntax for DDL table design in MSSQLServer 2014.

Click For Summary
SUMMARY

The discussion focuses on the syntax for Data Definition Language (DDL) table design in Microsoft SQL Server 2014. Key questions addressed include the order of attributes and constraints in table creation, the necessity of commas between attribute properties and constraints, and the separation of consecutive constraint statements. The user also inquires about identifying referenced attributes in an Entity-Relationship Diagram (ERD) when names differ. Resources such as Stack Overflow and MSDN are recommended for further guidance on DDL syntax and tools.

PREREQUISITES
  • Understanding of DDL syntax in SQL Server 2014
  • Familiarity with Entity-Relationship Diagrams (ERDs)
  • Knowledge of constraints in SQL, particularly foreign keys
  • Experience with SQL Server Management Studio (SSMS)
NEXT STEPS
  • Research the order of attributes and constraints in SQL Server DDL syntax
  • Learn about the use of commas in SQL constraint declarations
  • Explore how to interpret ERDs to identify referenced attributes
  • Utilize SQL Server Management Studio to generate DDL for existing tables
USEFUL FOR

Database developers, SQL Server administrators, and anyone involved in designing or managing database schemas using DDL in Microsoft SQL Server 2014.

WWGD
Science Advisor
Homework Helper
Messages
7,804
Reaction score
13,107
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:
Technology news on Phys.org

Similar threads

  • · Replies 7 ·
Replies
7
Views
1K
  • · Replies 5 ·
Replies
5
Views
1K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
Replies
2
Views
2K
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
5
Views
7K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K