create table candidate (
cand_id varchar(12) primary key, --
cand_id
name varchar(40)
-- cand_nm
);
create table contributor (
contbr_id integer primary key,
name varchar(40),
-- contbr_nm
city varchar(40),
-- contbr_city
state varchar(40),
-- contbr_st
zip varchar(20),
-- contbr_zip
employer varchar(60),
-- contbr_employer
occupation varchar(40)
-- contbr_occupation
);
create table contribution (
contb_id integer primary key,
cand_id varchar(12),
-- cand_id
contbr_id varchar(12),
-- contbr_id
amount numeric(6,2),
-- contb_receipt_amt
date varchar(20),
-- contb_receipt_dt
election_type varchar(20),
-- election_tp
tran_id varchar(20),
-- tran_id
foreign key (cand_id) references candidate,
foreign key (contbr_id) references contributor
);
-- 16. set the SQLite output to be a file named
'campaign-normal.sql'
.output 'campaign-normal.sql'
-- 17. output the candidate schema, and then all candidate rows
as SQL
-- insert statements.
-- Hint: the SQLite .mode command allows you to select that you
want
-- rows of a query to be output as SQL insert statements, and
the
-- table name to be specified.
-- 18. output the contributor schema, and then all contributor rows
as SQL
-- insert statements.
-- 19. output the contribution schema, and then all contribution
rows as SQL
-- insert statements.
-- 20. set the SQL output so that it no longer goes to a file
Queries:
-- ************ Creating candidate table ************
create table candidate (
cand_id varchar(12) primary key, -- cand_id
name varchar(40) -- cand_nm
);
-- ************ Creating contributor table ************
create table contributor (
contbr_id integer primary key,
name varchar(40), -- contbr_nm
city varchar(40), -- contbr_city
state varchar(40), -- contbr_st
zip varchar(20), -- contbr_zip
employer varchar(60), -- contbr_employer
occupation varchar(40) -- contbr_occupation
);
-- ************ Creating contribution table ************
create table contribution (
contb_id integer primary key,
cand_id varchar(12), -- cand_id
contbr_id varchar(12), -- contbr_id
amount numeric(6,2), -- contb_receipt_amt
date varchar(20), -- contb_receipt_dt
election_type varchar(20), -- election_tp
tran_id varchar(20), -- tran_id
foreign key (cand_id) references candidate,
foreign key (contbr_id) references contributor
);
-- ************ Insert 3 sample records into candidate table
*****************
INSERT INTO candidate VALUES('ID1234','Retheesh');
INSERT INTO candidate VALUES('ID1230','Sampath');
INSERT INTO candidate VALUES('ID1244','Ajay');
-- ************ Insert 2 sample records into contributor table
*****************
INSERT INTO contributor VALUES(100, "Kiran", "Trivandrum",
"Kerala", "695000", "ABCD", "Engineer");
INSERT INTO contributor VALUES(200, "John", "Kochi", "Kerala",
"695010", "XYZ", "Sales Executive");
-- ************ Insert 2 sample records into contribution table
*****************
INSERT INTO contribution VALUES(12500, 'ID1230', 100, 2000.00,
'20/05/2018', 'MLA', 'TRN12345234');
INSERT INTO contribution VALUES(12600, 'ID1230', 200, 250.00,
'23/11/2018', 'MP', 'TRN87354769');
INSERT INTO contribution VALUES(12700, 'ID1234', 200, 6000.00,
'07/10/2018', 'MLA', 'TRN76767898');
-- 16. set the SQLite output to be a file named
'campaign-normal.sql'
-- ************ setting output file for sql results
*****************
.output C:\\Users\\Retheesh\\Desktop\\test\\campaign-normal.sql
-- 17. output the candidate schema, and then all candidate rows
as SQL insert statements.
-- ************ setting mode as sql insert query for candidate
table *****************
.mode insert "candidate"
-- ************ getting schema of candidate table
*****************
.schema candidate
-- ************ getting all records from candidate table as
insert queries *****************
select * from candidate;
-- 18. output the contributor schema, and then all contributor
rows as SQL insert statements.
-- ************ setting mode as sql insert query for contributor
table *****************
.mode insert "contributor"
-- ************ getting schema of contributor table
*****************
.schema contributor
-- ************ getting all records from contributor table as
insert queries *****************
select * from contributor;
-- 19. output the contribution schema, and then all contribution
rows as SQL insert statements.
-- ************ setting mode as sql insert query for contribution
table *****************
.mode insert "contribution"
-- ************ getting schema of contribution table
*****************
.schema contribution
-- ************ getting all records from contribution table as
insert queries *****************
select * from contribution;
-- 20. set the SQL output so that it no longer goes to a
file
-- ************ setting output *****************
.output stdout
Screenshot of queries execution:


Output file screenshot:

create table candidate ( cand_id varchar(12) primary key, -- cand_id name varchar(40) --...
CREATE TABLE person ( pid INTEGER NOT NULL ,pname VARCHAR(30) NOT NULL ,PRIMARY KEY (pid) ); CREATE TABLE organization ( oid INTEGER NOT NULL ,oname VARCHAR(30) NOT NULL ,PRIMARY KEY (oid) ); CREATE TABLE venue ( vid INTEGER NOT NULL ,area CHAR(1) NOT NULL ,capacity INTEGER NOT NULL ,PRIMARY KEY (vid) ); CREATE TABLE calendar ( vid INTEGER NOT NULL ,date DATE NOT NULL ,price NUMERIC(6,2) NOT NULL ,PRIMARY KEY(vid,date) ,FOREIGN KEY(vid) REFERENCES venue(vid) ); CREATE TABLE event ( eid...
CREATE TABLE Gender ( gender CHAR(1), description VARCHAR(10), PRIMARY KEY (gender) ); CREATE TABLE People ( ID INT, name VARCHAR(50), gender CHAR(1), height FLOAT, PRIMARY KEY (ID), FOREIGN KEY (gender) REFERENCES Gender (gender) ); CREATE TABLE Sports ( ID INT, name VARCHAR(50), record FLOAT, PRIMARY KEY (ID), UNIQUE (name) ); CREATE TABLE Competitions ( ID INT, place VARCHAR(50), held DATE, PRIMARY KEY (ID) ); CREATE TABLE Results ( peopleID INT NOT NULL, competitionID INT NOT NULL, sportID INT NOT NULL,...
CREATE TABLE Users ( userId varchar (30) NOT NULL, pass varchar (30), fname varchar (50), lname varchar (50), email varchar (50), gender char(1), age integer, banned boolean, PRIMARY KEY (userId), UNIQUE(email)) CREATE TABLE FavSellers ( userId varchar (30), sellerId varchar (30), PRIMARY KEY (userId, sellerId), FOREIGN KEY(userId) references Users, FOREIGN KEY(sellerId) references Users(userId)) CREATE TABLE Items ( itemId integer, title varchar (50), ...
CREATE TABLE DEPT (
DEPTNO INTEGER NOT NULL,
DNAME VARCHAR(14),
LOC VARCHAR(13),
PRIMARY KEY (DEPTNO));
INSERT INTO DEPT VALUES (10,'SPORTS','NEW YORK');
INSERT INTO DEPT VALUES (20,'HOME','DALLAS');
INSERT INTO DEPT VALUES (30,'OUTDOOR','CHICAGO');
INSERT INTO DEPT VALUES (40,'CLOTHING','BOSTON');
CREATE TABLE EMP (
EMPNO INTEGER NOT NULL,
ENAME VARCHAR(10),
JOB VARCHAR(9),
MGR INTEGER,
SAL FLOAT,
COMM FLOAT,
DEPTNO INTEGER NOT NULL,
FOREIGN KEY (DEPTNO) REFERENCES DEPT (DEPTNO),
FOREIGN KEY (MGR) REFERENCES EMP(EMPNO),
PRIMARY KEY (EMPNO));
INSERT INTO EMP VALUES (7839,'KING','PRESIDENT',NULL,
5000,NULL,10);
INSERT INTO...
Help In Database: Next comes the data entry: Make up data for your database, or find real data. You can enter the data with INSERT statements, but it is much easier to use PhpAdmin. It has a form where you can type the data directly. Alternatively, you can use PhpAdmin to import CSV data (comma-separated values), which you can export from Excel. Include at least 3 rows in each of the entity relations, and as many rows as you need...
-- Schema definition
create table Customer (
cid smallint not null,
name varchar(20),
city varchar(15),
constraint customer_pk
primary key (cid)
);
create table Club (
club varchar(15) not null,
desc varchar(50),
constraint club_pk
primary key
(club)
);
create table Member (
club varchar(15) not null,
cid
smallint not null,
constraint member_pk
primary key (club,
cid),
constraint mem_fk_club
foreign key (club)
references Club,
constraint mem_fk_cust...
CREATE TABLE actor( id INTEGER NOT NULL, name VARCHAR(100), PRIMARY KEY (id) ); SELECT name FROM actor WHERE name LIKE 'M%'; Q. How to run explain plan on the above query and display its output?
Given the schema, write a query and subquery
to do the following:
CREATE TABLE Majors major VARCHAR(12), description VARCHAR, PRIMARY KEY (major) ); CREATE TABLE Course ( courseMajor VARCHAR(12), courseNo VARCHAR(6), credits INTEGER NOT NULL, enroll_limit INTEGER, PRIMARY KEY(courseNo, courseMajor), FOREIGN KEY (courseMajor) REFERENCES Majors (major) CREATE TABLE Tracks trackMajor VARCHAR(12), trackCode VARCHAR(10), title VARCHAR, PRIMARY KEY(trackMajor, trackCode), FOREIGN KEY (trackMajor) REFERENCES Majors(major) CREATE TABLE Student ( SID CHAR(8), sName VARCHAR(30), studentMajor VARCHAR(12), trackCode VARCHAR(10), PRIMARY KEY(SID), FOREIGN KEY (studentMajor,...
Create a new database and execute the code below in SQL Server’s query window to create the database tables. CREATE TABLE PhysicianSpecialties (SpecialtyID integer, SpecialtyName varchar(50), CONSTRAINT PK_PhysicianSpecialties PRIMARY KEY (SpecialtyID)) go CREATE TABLE ZipCodes (ZipCode varchar(10), City varchar(50), State varchar(2), CONSTRAINT PK_ZipCodes PRIMARY KEY (ZipCode)) go CREATE TABLE PhysicianPractices (PracticeID integer, PracticeName varchar(50), Address_Line1 varchar(50), Address_Line2 varchar(50), ZipCode varchar(10), Phone varchar(14), Fax varchar(14), WebsiteURL varchar(50), CONSTRAINT PK_PhysicianPractices PRIMARY KEY (PracticeID), CONSTRAINT FK_PhysicianPractices_ZipCodes FOREIGN KEY (ZipCode) REFERENCES Zipcodes) go CREATE...
CREATE TABLE Bill( bill_id char(15) PRIMARY KEY, bill_name VARCHAR(150) NOT NULL, dateOfVoteCommittee date, dateOfVote date, isPassed tinyint(1) CHECK (isPassed IN (0,1)), date_signed date, isVeto tinyint(1) CHECK (isVeto IN (0,1)), dateOfVote_override date, proposed_person_id INT, committee_id INT, foreign key(proposed_person_id) REFERENCES Congressman(person_id), foreign key(committee_id) REFERENCES Committee(committee_id) ); INSERT INTO Bill (bill_id, bill_name, dateOfVote, isPassed, date_signed, isVeto, dateOfVote_override, proposed_person_id, commitee_id) VALUES(1,'SB2 Florida Statutes',DATE'2019-03-27',1,DATE'2019-03-27',0,23,); *I am getting this error - mysql Mysql doesn't like the date entries in the insert statement. Schema above for reference.