Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5940633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:59:43+00:00 2026-05-22T15:59:43+00:00

Given the following data table definitions in SQLite Version 3.7.5: CREATE TABLE [Books] (

  • 0

Given the following data table definitions in SQLite Version 3.7.5:

CREATE TABLE [Books] (
  [Title] VARCHAR(125) NOT NULL, 
  [YearPublished] INT, 
  CONSTRAINT [CK_YearPublished] CHECK(YearPublished >= 1400));

CREATE TABLE [People] (
  [FirstName] VARCHAR(25) NOT NULL, 
  [LastName] VARCHAR(45) NOT NULL, 
  [MiddleName] VARCHAR(25), 
  CONSTRAINT [UQ_PersonName] UNIQUE([FirstName], [LastName], [MiddleName]));

CREATE TABLE [BooksAuthorsXRef] (
  [BookID] INT NOT NULL CONSTRAINT [FK_BookID] REFERENCES [Books]([rowid]), 
  [PersonID] INT NOT NULL CONSTRAINT [FK_PersonID] REFERENCES [People]([rowid]));

What SQL command can I use to populate the BookID and PersonID field values in the BooksAuthorsXRef data table to use the values for the rowid for a specific Title in the Books table to be associated with the rowid in the Persons table for a given LastName, FirstName, and MiddleName set of values?

I’ve already populated the Books table with one record;

INSERT INTO
       Books       
VALUES
      ('Stingray Shuffle', 2003);

And, the Persons table has been populated with the following record:

INSERT INTO 
       People
       (LastName, FirstName)       
VALUES
       ('Dorsey', 'Tim')      

What SQL command would I use in SQLite to define that Tim Dorsey (Persons rowid = 1) is the author of the book entitled “Stingray Shuffle” in the Books table (Books rowid = 1)?

Also, based on the data table definitions, are any changes needed to make adding and changing Books and Persons cross reference records in the BooksAuthorsXRef data table more managable and easier while maintaining some degree of referential integrity?

Thank you in advance for your time, help and patience.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:59:43+00:00Added an answer on May 22, 2026 at 3:59 pm

    If you’ve an existing table with all of the book + person data in it, you can do the following:

    INSERT INTO BooksAuthorsXRef
    SELECT      B.[rowid], P.[rowid]
    FROM        XRefTemp T
    INNER JOIN  Books B
    ON          B.Title = T.Title
    INNER JOIN  People P
    ON          P.FirstName = T.FirstName
    AND         COALESCE(P.MiddleName, '') = COALESCE(T.MiddleName, '')
    AND         P.LastName = T.LastName
    

    When inserting individual records, the last_insert_rowid() function will give you the rowid for the Book / People record you’ve just inserted.

    To insert a record for an existing Book / Person, use:

    INSERT INTO BooksAuthorsXRef
    SELECT      B.[rowid], P.[rowid]
    FROM        Books B
    INNER JOIN  People P
    ON          P.FirstName = 'TheFirstName'
    AND         COALESCE(P.MiddleName, '') = 'TheMiddleName or empty if none'
    AND         P.LastName = 'TheLastName'
    WHERE       B.Title = 'TheBookTitle'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following: declare @a table ( pkid int, value int ) declare @b
I was asked the following Question: How would you store the data given below(which
Suppose I have a table with following data: gameId difficultyLevel numberOfQuestions -------------------------------------------- 1 1
Imagine a table emp : CREATE TABLE emp ( id NUMBER , name VARCHAR
Given a database with records like the following Table: AuditLog Fields: ID | USERID
Given following Ruby statements: (Read input and store each word in array removing spaces
Given the following XML: <current> <login_name>jd</login_name> </current> <people> <person> <first>John</first> <last>Doe</last> <login_name>jd</login_name> </preson> <person>
Given the following: List<List<Option>> optionLists; what would be a quick way to determine the
Given the following example, why do I have to explicitly use the statement b->A::DoSomething()
Given the following XML structure <html> <body> <div> <span>Test: Text2</span> </div> <div> <span>Test: Text3</span>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.