Syntax for DDL table design in MSSQLServer 2014.

In summary, the conversation discusses learning DDL table design in MSSL2014 and the need for a tool to extract the DDL code from a table printout. The person also asks questions about the necessary order of attributes and constraints, the use of commas in declaration and constraint statements, and how to determine which attribute is being referenced in a Foreign Key constraint. The conversation also mentions resources for DDL syntax and examples of creating a table.
  • #1
WWGD
Science Advisor
Gold Member
7,019
10,579
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
  • #2
  • Like
Likes WWGD

Related to Syntax for DDL table design in MSSQLServer 2014.

What is the purpose of DDL table design in MSSQLServer 2014?

The purpose of DDL (Data Definition Language) table design in MSSQLServer 2014 is to define the structure and properties of a database table. It allows you to specify the data types, constraints, and relationships of the data within the table.

What are the basic elements of DDL table design in MSSQLServer 2014?

The basic elements of DDL table design in MSSQLServer 2014 include the table name, column names and data types, primary and foreign keys, and any constraints or indexes.

How do you create a new table using DDL in MSSQLServer 2014?

To create a new table using DDL in MSSQLServer 2014, you would use the CREATE TABLE statement followed by the table name and a list of column names and data types. You can also specify any constraints or indexes within the statement.

What is the difference between a primary key and a foreign key in DDL table design?

A primary key is a column or set of columns that uniquely identifies each row in a table. It is used to enforce data integrity and ensure that there are no duplicate values. A foreign key, on the other hand, is a column or set of columns that refers to the primary key of another table. It is used to establish a relationship between two tables.

How do you modify an existing table using DDL in MSSQLServer 2014?

To modify an existing table using DDL in MSSQLServer 2014, you would use the ALTER TABLE statement followed by the table name and the specific changes you want to make. These changes can include adding or dropping columns, changing data types, or adding constraints or indexes.

Similar threads

  • Programming and Computer Science
Replies
7
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
669
  • Programming and Computer Science
Replies
14
Views
1K
  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
5
Views
5K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
5
Views
2K
  • Computing and Technology
Replies
3
Views
2K
Back
Top