Question

This is question from my Database Management Systems class. Explain the essential format of the CREATE...

This is question from my Database Management Systems class.

Explain the essential format of the CREATE TABLE statement. Include an example.

Explain how relationships are created using SQL. Include an example.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1)

The syntax of create table statement is given as:

CREATE TABLE table_name (
    column1 datatype,
    column2 datatype,
    column3 datatype,
   ....
);

Here, the column parameters specify the names of the columns of the table.

The datatype parameter specifies the type of data the column can hold (e.g. integer, real, varchar, etc.).

Example) Here is the SQL query to create a table called Employee.

CREATE TABLE Employee (
    SSN int,
    LastName varchar(255),
    FirstName varchar(255),
    Address varchar(255),
    City varchar(255)
);

2)

Relationships in SQL are created using foreign key referential integrity constraints.

For example, below is a foreign key constraint to create a relationship between Employee and Department.

ALTER TABLE Employee
ADD FOREIGN KEY (DeptNo) REFERENCES Department(DeptNo);

Add a comment
Know the answer?
Add Answer to:
This is question from my Database Management Systems class. Explain the essential format of the CREATE...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT