SQL Foundations I Module 1

Generate statements (ddl) to create all objects

Only editable by group admins

  • Last updated August 24, 2016 at 1:07 PM
  • Evidence visible to public
Generate statements (ddl) to create all objects from the ERD. These must be valid SQL statements. It is recommended you use SQLFiddle to post working examples. Submit an URL where your work is located, with valid code.

All posted evidence

DDL Statements to create objects:

DDL Statements to create objects:     create or replace table teacher (     teach_id int primary key,     name varchar(50),     salary decimal(6,0)     );     create or replace table grade (     id int primary key,     student_id int,     teacher_id int,     term_id int,     grade_varchar varchar(40),     grade_num int,     status varchar(10),    subject_id int,    foreign key (teacher_id) references teacher(teach_id),     foreign key (student_id) references student(student_id),     );   create or replace table student (     student_id int primary key,     student_name varchar(40),     creditsearned decimal(5,2),    dob datetime     );     


https://parkland1-my.sharepoint.com/:w:/r/personal/sdow3_stu_parkland_edu/_layouts/15/Doc.aspx?sourcedoc=%7B9ADBB784-B847-4BF0-BE34-1D06976E186B%7D&file=Module%201_%20CSC176%20Data%20Systems_Sharon%20Dow%20102318.docx&action=default&mobileredirect=true
sdow3 About 6 years ago
id int primary key,     name varchar(50),     type varchar(20),     quantity int,     measurement varchar(10)     );     create or replace table teacher (     id int primary key,     name varchar(50),     type varchar(20),     quantity int,(5)     measurement varchar(10)     );     create or replace table Subject (id int primary key,     name varchar(50),     type varchar(20),     quantity int,     measurement varchar(10)     );     create or replace table grade (     id int primary key,     name varchar(50),     type varchar(20),     quantity int,     measurement varchar(10)     ); create or replace table student (     School_id int,     Teacher_id int,     Subject_id int,     Student_id int,     grade_id int,         foreign key (school_id) references school(school_id),      foreign key (teacher_id) references teacher(teacher_id),     foreign key (subject_id) references subject(subject_id),     FOREIGN KEY (grade_id) references grade(grade_id)     );     Then revised to     create or replace table Subject (     subject_id int primary key,     name varchar(50),     type varchar(20),     quantity int,     measurement varchar(10)     );     create or replace table student (     student_id int primary key,     name varchar(50),     type varchar(20),     quantity int,     measurement varchar(10)     );     CREATE or replace table studentrecord (Subject_id int,     student_id int,     foreign key (subject_id) references subject(subject_id),     FOREIGN KEY (student_id) references student(student_id)     );
sdow3 About 6 years ago
CREATE TABLE IF NOT EXISTS PROGRAM_OF_STUDY
(
  ID INT NOT NULL,
  PROGRAM_ID TEXT NOT NULL,
  PROGRAM_TITLE VARCHAR (30) NOT NULL, 
  PRIMARY KEY (ID)
 );
 
 CREATE TABLE DISCIPLINE
 (
   DISCIPLINE_ID INT NOT NULL,
   CODE VARCHAR(15) NOT NULL, 
   DISCIPLINE_TITLE TEXT NOT NULL,
   NUM_CREDITS INT NOT NULL, 
   HOUR_TYPE VARCHAR(6) NOT NULL,
   FOREIGN KEY (DISCIPLINE_ID) REFERENCES PROGRAM_OF_STUDY (ID)
  );
  
  CREATE TABLE STUDENT
  (
    STUDENT_ID INT NOT NULL,
    STUDENT_NUMBER VARCHAR(4) NOT NULL, 
    STUDENT_FNAME TEXT NOT NULL, 
    STUDENT_LNAME TEXT NOT NULL, 
    FOREIGN KEY (STUDENT_ID) REFERENCES PROGRAM_OF_STUDY (ID)
   );
mangai Over 6 years ago

Create statements for Module I Task II

CREATE TABLE University
(
  University_ID INT NOT NULL,
  University_Name VARCHAR(40) NOT NULL,
  PRIMARY KEY (University_ID)
);

CREATE TABLE Course
(
  Professor VARCHAR(30) NOT NULL,
  Course_No INT NOT NULL,
  Section INT NOT NULL,
  Credit_Hours INT NOT NULL,
  Course_Name VARCHAR(30) NOT NULL,
  University_ID INT NOT NULL,
  PRIMARY KEY (Course_No),
  FOREIGN KEY (University_ID) REFERENCES University(University_ID)
);

CREATE TABLE Student
(
  Username VARCHAR(30) NOT NULL,
  ID INT NOT NULL,
  Major VARCHAR(30) NOT NULL,
  University_ID INT NOT NULL,
  Course_No INT NOT NULL,
  PRIMARY KEY (ID),
  FOREIGN KEY (University_ID) REFERENCES University(University_ID),
  FOREIGN KEY (Course_No) REFERENCES Course(Course_No)
);
mpurnell1 Almost 7 years ago

This is the creation of the tables.

CREATE TABLE Students
(
  id int PRIMARY KEY,
  name CHAR(30) NOT NULL,
  classroom_id INT NOT NULL,
  class_id CHAR(30) NOT NULL,
  FOREIGN KEY (classroom_id) REFERENCES classrooms(Classroom_id),
  FOREIGN KEY (class_id) REFERENCES Class (Class_id)
  );
  
CREATE TABLE Classrooms
(
 Classroom_id INT NOT NULL,
 Classroom_number INT NOT NULL,
 PRIMARY KEY (Classroom_id)
);

CREATE TABLE Class
(
 Class_id INT NOT NULL,
 Class_id CHAR(30) NOT NULL,
 PRIMARY KEY (Class_id)
);

rvargas8 About 7 years ago

The three tables with statments.

CREATE TABLE students
(
  PRIMARY KEY(names),
  Jimbo CHAR(30) NOT NULL,
  Bobby CHAR(30) NOT NULL,
  Claire CHAR(30) NOT NULL,
  FOREIGN KEY (ID) REFERENCES Finishes(ID),
  FOREIGN KEY (Age) REFERENCES Finishes(Age),
  );

CREATE TABLE Age
(
    PRIMARY KEY (Age)
  16 INT NOT NULL,
  17 INT NOT NULL,
  18 INT NOT NULL,
  PRIMARY KEY (age)
);

CREATE TABLE ids
(
 PRIMARY KEY (ID)
 123 INT NOT NULL,
 321 INT NOT NULL,
 987 INT NOT NULL,
  
  
  
);




rvargas8 About 7 years ago

3 Create statements for my 3 tables generated in ERDplus. Modified the create statement for the Signs table to put in my desired order

CREATE TABLE Materials
(
  mat_id INT NOT NULL,
  name VARCHAR(30) NOT NULL,
  cost FLOAT NOT NULL,
  PRIMARY KEY (mat_id)
);

CREATE TABLE Finishes
(
  finish_id INT NOT NULL,
  name VARCHAR(30) NOT NULL,
  cost FLOAT NOT NULL,
  PRIMARY KEY (finish_id)
);

CREATE TABLE Signs
(
  id INT NOT NULL,
  hor_dimens FLOAT NOT NULL,
  vert_dimens FLOAT NOT NULL,
  mat_id INT NOT NULL,
  finish_id INT NOT NULL,
  quantity INT NOT NULL,
  cost FLOAT NOT NULL,
  PRIMARY KEY (id),
  FOREIGN KEY (finish_id) REFERENCES Finishes(finish_id),
  FOREIGN KEY (mat_id) REFERENCES Materials(mat_id)
);
jmfisher About 7 years ago

I made 3 tables relating back to the College table. I set primary keys (e.g. ID_#, College_ID) and based my foreign keys on them.

CREATE TABLE College
(
Major VARCHAR(30) NOT NULL,
Department VARCHAR(30) NOT NULL,
College_Name VARCHAR(30) NOT NULL,
College_ID INT NOT NULL,
PRIMARY KEY(College_ID)
);

CREATE TABLE Course
(
TA VARCHAR(40) NOT NULL,
Professor VARCHAR(40) NOT NULL,
Section INT NOT NULL,
Course_ID INT NOT NULL,
Course_Name VARCHAR(20) NOT NULL,
College_ID INT NOT NULL, 
PRIMARY KEY(Course_ID),
FOREIGN KEY(College_ID) REFERENCES College(College_ID)
);

CREATE TABLE Student
(
Major VARCHAR(30) NOT NULL,
Username VARCHAR(10) NOT NULL,
ID_# INT NOT NULL,
Course_ID INT NOT NULL,
College_ID INT NOT NULL,
PRIMARY KEY(ID_#),
FOREIGN KEY(Course_ID) REFERENCES Course(Course_ID),
FOREIGN KEY(College_ID) REFERENCES College(College_ID)
);

vbecu1 Almost 8 years ago

Three Create Statements

Create Table Soccer_Players(

Player_ID Int(10),
Name VARCHAR(50),
Age Int(10),
Salary VARCHAR(100),
Net_Worth(100),
Team VARCHAR(100),
);

Create Table Stadiums(

Stadium_ID INT(10),
Name VARCHAR(100),
Capacity VARCHAR(100),
Location VARCHAR(100)
);

Create Table Leagues(

League_id Int(10),
Name VARCHAR(100),
Number_of_Teams INT(10),
YOB INT,
Location VARCHAR(100)
);


franciscocruz11 About 8 years ago

code

dustinninja About 8 years ago

Excerpt from the complete ddl: http://sqlfiddle.com/#!9/2047e0

CREATE TABLE food

name VARCHAR(12) NOT NULL,  quantity INT NOT NULL,  PRIMARY KEY (name)
);

CREATE TABLE species

name VARCHAR(12) NOT NULL,  location VARCHAR(12) NOT NULL, diet VARCHAR(12) NOT NULL,  PRIMARY KEY (name),  FOREIGN KEY (diet) REFERENCES food(name)
);

CREATE TABLE pets

name VARCHAR(12) NOT NULL,  sex VARCHAR(1) NOT NULL,  species VARCHAR(12) NOT NULL,  color VARCHAR(8) NOT NULL,  PRIMARY KEY (name),  FOREIGN KEY (species) REFERENCES species(name));
jaco About 8 years ago

Task 2

randyiv About 8 years ago