SYM 400 Tables Keys and Constraints

docx

School

Grand Canyon University *

*We aren’t endorsed by this school

Course

400

Subject

Computer Science

Date

Jan 9, 2024

Type

docx

Pages

6

Uploaded by PeanutButterEater102

Report
Tables, Keys, and Constraints 1 SYM 400 Introduction to Database Structures
Tables, Keys, and Constraints 2 First I need to log into this week’s assignment through LopesCloud. 1. C reate a new table called Birthday with the following columns: BusinessEntityId column as an integer, and a DoB (Date of Birth) column in as date. To do this I type in the following query:
Tables, Keys, and Constraints 3 Create Table DateofBirth( BusinessEntityId int, DoB Date ); The table already exists so to pull up the DateofBirth table I use the command Select * and in line two From DateofBirth:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Tables, Keys, and Constraints 4 2. Add a constraint to make BusinessEntityID a primary key. To do this I type in the following command: ALTER TABLE DateofBirth ALTER COLUMN BusinessEntityId int NOT NULL; GO ALTER TABLE DateofBirth ADD PRIMARY KEY (BusinessEntityId); 3. Insert one record for BusinessEntityID 1 and include 1990/01/01 as the birthday. To do this I type in the following command: INSERT INTO DateofBirth (BusinessEntityId, DoB) VALUES (1, ‘1990-01-01’);
Tables, Keys, and Constraints 5 I then received a 1 row affected message indicating it only changed the 1 record. 4. Once added, query your new table showing the new record. This is a test to make sure my new table shows the new date of birth is displayed when I execute the following command: SELECT * FROM DateofBirth
Tables, Keys, and Constraints 6 This pulls up BusinessEntityId number 1 and date of birth 1990-01-01. Lastly, I saved the query as a .sql file in my folders drive which concludes the assignment
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help