Question

Write the SQL statements for creating a table Event with primary key e_id, and an event...

Write the SQL statements for creating a table Event with primary key e_id, and an event date, e_date that cannot be null.

Also write the statements to create a table Participant with primary key p_id, a name that can be up to 30 characters long but may be shorter, and an event e_id as a foreign key that references the corresponding event.

Homework Answers

Answer #1


1)CREATE TABLE Event (
e_id int NOT NULL PRIMARY KEY,
e_date DATE NOT NULL
);

2)CREATE TABLE Participant (
p_id int NOT NULL PRIMARY KEY,
name VARCHAR(30) NOT NULL,
e_id int FOREIGN KEY REFERENCES Event(e_id)
);

Note: Used VARCHAR because upto 30 characters.if fixed characters means use CHAR

Know the answer?
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
Similar Questions
Created the database and all the tables in phpMyadmin. In addition, write all the sql statements...
Created the database and all the tables in phpMyadmin. In addition, write all the sql statements used in perforing the tasks in a word document and submit that for grading. Lab 1: CREATE STATEMENT This statement is used to create a database or a table. CREATE DATABASE This statement is used to create a database Syntax: CREATE DATABASE database_name; OR CREATE SCHEMA database_name; Example: CREATE DATABASE Nyumbani; OR CREATE SCHEMA Nyumbani ; CREATE TABLE This SQL statement is used to...
Perform SQL queries in the given data structure. write an SQL query that gives the number...
Perform SQL queries in the given data structure. write an SQL query that gives the number of courses taken for every student in the student table. For each instructor, show the instructor name and the number of sections that have been taught by that instructor. You do not need to include instructors who have never taught a section. List in order of decreasing the number of sections taught. Give the number of semester/year combinations in which sections have been offered....
Write a SQL statement which joins the parts table with the supplier table and lists the...
Write a SQL statement which joins the parts table with the supplier table and lists the part_name, supplier_name for all parts in the part table. The supplier_id column in the suppliers table is the primary key in the suppliers table, and this key has been exported to the parts table where it is a foreign key. You should use an inner join for this query. Write a SQL statement which joins the parts table with the suppliers table and lists...
Space X Bank CREATE TABLE Branch(BranchIDNumber VARCHAR(15) PRIMARY KEY NOT NULL, BranchName VARCHAR(6) NOT NULL, Address...
Space X Bank CREATE TABLE Branch(BranchIDNumber VARCHAR(15) PRIMARY KEY NOT NULL, BranchName VARCHAR(6) NOT NULL, Address VARCHAR(50) NOT NULL, City TEXT NULL, State CHAR(2) NULL, ZipCode INT(11) NOT NULL, OfficeNum VARCHAR(15) NOT NULL, FaxNum VARCHAR(15) NOT NULL); CREATE TABLE Employee(EmployeeIDNumber VARCHAR(15) NOT NULL,FirstName VARCHAR(35) NOT NULL, LastName VARCHAR(35) NOT NULL, Email VARCHAR(100) NOT NULL, BranchIDNumber VARCHAR(11) NOT NULL, FOREIGN KEY(BranchIDNumber) REFERENCES Branch(BranchIDNumber), JobTitle ENUM("Manager","Staff") NOT NULL, Salary DECIMAL(8, 2) NOT NULL, HomeNumber VARCHAR(13) NULL, CellNumber VARCHAR(13) NOT NULL); CREATE TABLE...
Write the SQL code that will create only the table structure for a table named EMP_1....
Write the SQL code that will create only the table structure for a table named EMP_1. This table will be a subset of the EMPLOYEE table. The basic EMP_1 table structure is summarized in the following table. Use EMP_NUM as the primary key. Note that the JOB_CODE is the FK to JOB so be certain to enforce referential integrity. Your code should also prevent null entries in EMP_LNAME and EMP_FNAME.
SQL allows a foreign-key dependency to refer to the same relation, as in the following example:...
SQL allows a foreign-key dependency to refer to the same relation, as in the following example: create table manager ( employee_ID char(20), Manager_ID char(20), primary key employee_ID, foreign key (manager_ID) references manager(employee_ID) on update cascade ) Here, employee_ID is a key to the table manager, meaning that each employee has at most one manager. The foreign-key clause requires that every manager also be an employee. Explain exactly what happens when a tuple in the relation manager is updated. Specify all...
Write a script to create the following tables with attributes as specified(SQL) Customer table with Customer’s...
Write a script to create the following tables with attributes as specified(SQL) Customer table with Customer’s id, name, address, city as varchar, customer’s date of birth as date type and zip code number where the customers id is the primary key in the table, name and date of birth are mandatory. Id has a 10-character limit, name, address and city have a 50-character limit, zip has a 5-character limit Product Table with Product id, description and finish as varchar, price...
This is my code but I am having trouble with the SECTION and REGISTRATION table. The...
This is my code but I am having trouble with the SECTION and REGISTRATION table. The error for section says course id isn't a column and with registration, it says there are no foreign key but that is all that is in the registration table. CREATE TABLE STUDENT(StudentID integer, StudentName char(25) NOT NULL, primary key(StudentName)) CREATE TABLE FACULTY(FacultyID integer, FacultyName char(25) NOT NULL, primary key(FacultyID)) CREATE TABLE COURSE(CourseID integer, CourseName char(15) NOT NULL, primary key(CourseID)) CREATE TABLE QUALIFIED(DateQualified date, FacultyID...
I get Error code 1215 Cannot add foreign key constraint in MySQL work bench lines 10,...
I get Error code 1215 Cannot add foreign key constraint in MySQL work bench lines 10, 11 & 14. I've tried to correct it and it's still wrong. I'm new to SQL and about to give up. Create Table Employee( EmployeeNumber   Int           NOT NULL AUTO_INCREMENT, FirstName       Char(25)   NOT NULL, LastName       Char(25)   NOT NULL, Department       Char(35)   NOT NULL DEFAULT 'Human Resources', Position       Char(35)   NULL, Supervisor       Int           NULL, OfficePhone       Char(12)   NULL, EmailAddress  ...
Purpose: The purpose of this assignment is to provide an opportunity for you to write SQL...
Purpose: The purpose of this assignment is to provide an opportunity for you to write SQL statements to create tables and insert data into tables. Skills: Learn and practice the techniques of writing SQL statements using SQL Server Management Studio(SSMS).   Knowledge: By doing this assignment you will learn to use SSMS and write SQL statements to create new tables and insert data into the tables. Tasks: Use the following figure for the tasks below: [15 points] Write SQL statements to...