troubleshooting Question

SQLite queries needing review

Avatar of curiouswebster
curiouswebsterFlag for United States of America asked on
SQLDatabases
8 Comments6 Solutions13 ViewsLast Modified:
Please review my schema and point out any issues...thanks.

CREATE TABLE IF NOT EXISTS status (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    status TEXT NOT NULL,
    comment TEXT NOT NULL,
    create_date TEXT NOT NULL,
    update_date TEXT NOT NULL
);

INSERT INTO status (status, comment, create_date, update_date) VALUES
('Active', 'The Contact is Active.', datetime('now','localtime'), datetime('now','localtime')),
('Inactive', 'The Contact is no longer Active.', datetime('now','localtime'), datetime('now','localtime')),
('Disabled', 'The Contact has been Disabled.', datetime('now','localtime'), datetime('now','localtime')),
('Unsubscribed', 'The Contact has Unsubscribed from any further contact.', datetime('now','localtime'), datetime('now','localtime')),
('Pending', 'The Contact has been Created but not Activated.', datetime('now','localtime'), datetime('now','localtime'));

CREATE TABLE IF NOT EXISTS contacts (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    email TEXT,
    voterid TEXT,
    fname TEXT,
    lname TEXT NOT NULL,
    street TEXT,
    city TEXT,
    state TEXT,
    zip TEXT,
    cell TEXT,
    company TEXT,
    title TEXT,
    create_date TEXT NOT NULL,
    update_date TEXT NOT NULL,
    statusid INTEGER,
    FOREIGN KEY (statusid) REFERENCES status(id)
);

INSERT INTO contacts (voterid, fname, lname, street, city, state, zip, statusid, create_date, update_date) VALUES
('105008499','JOHN','SMITH','29 ROYAL DR','TALLAHASSEE','FL','30309', 5, datetime('now','localtime'), datetime('now','localtime'));


It works:


 


ASKER CERTIFIED SOLUTION
Bembi
CEO

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 6 Answers and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 6 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros