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 574963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:53:14+00:00 2026-05-13T13:53:14+00:00

I have a Database that has the following relations: Transaction->Purchase->Item->Schedule Transaction – self explanitory

  • 0

I have a Database that has the following relations:

Transaction->Purchase->Item->Schedule

Transaction - self explanitory
Purchase - any purchase info that relates to the item being purchased (quantity, if the user purchases more than one item).  A given Transaction can have more than one Purchase_ID tied to it.
Item - Stores Item info and relates it to individual clients.
Schedule - determines the price of an item at a given time of day.

I need to execute a query that must select a series of values from Schedule based on if Transaction.TimeStamp is within a supplied date-range. The query needs to select a value from Schedule based on it’s primary key. The primary key is not traceable from transaction.

In order to resolve this issue, I have decided to create a table to link Transaction DIRECTLY to Schedule’s primary.

Recently I discovered Table Views – would this be an appropriate situation to make a table "view"? Or should I just create an ‘actual’ table TransactionSchedule?

transactionSchedule
Transaction_ID    Schedule_ID

My problem is I do not understand the specifics of when a table view is useful/what the benefits are.

Is having a individual table to Trace Transaction->Schedule overkill?

Really any general guidance with this problem would be much appreciated.

EDIT: this query is ONLY for retrieving data that has already been entered

–thanks

  • 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-13T13:53:15+00:00Added an answer on May 13, 2026 at 1:53 pm

    I would strongly urge you to copy the price from the schedule directly to Purchase as soon as you’re inserting that. That way, you have solved your problem, and at the same time, prevented from a different price being charged to the customer later on if you accidentally (or intentionally) change the schedule.

    As for relating to the primary key of schedule, and this not being traceable from a transation: that is a sign of bad design. I mean, think about it – you have a timestamp in transaction, a schedule by definition is placed in time using a from and to timestamp – why can’t you relate them? AFAICS, primary key of schedule should be item_id, from_timestamp, to_timestamp

    Assuming your schedule table has a from and to timestamp My query would be

    SELECT     ..your columns..
    FROM       Transaction t
    INNER JOIN Purchase    p
    ON         t.id        = p.transaction_id
    INNER JOIN Item        i
    ON         p.id        = i.purchase_id
    INNER JOIN Schedule    s
    ON         i.id        = s.item_id
    AND        t.timestamp BETWEEN s.from_timestamp
                               AND s.to_timestamp
    

    As for, should you use a view or not – really, it’s up to you. A view does not work better or worse than a query, the only difference is that the definition is stored in the database. The main advantages of that are

    • people can reuse the definition without copying the query (and messing it up), the
    • you can change the schema to some extent and hide that from the application provided you update the view accordingly (this latter advantage is often overestimated)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL database that has the following table: Table: PhoneRecords -------------- ID(identity
I have a simple database that has the following relation Each Question has one
I have an table in my MySql database that has the following columns: -
I have a simple database that has the following relation. Each Server has one
I have a database that has node & nodetype tables. Nodes table NodeID ParentNodeID
I have an existing database that has some testing data into and I'm interested
I have a database structure that has a Person table which contains fields such
I have a SQL database that has a table with a field set to
I have inherited a database that has a lot of cursors in it, and
I have a database table that has a Unique Key constraint defined to avoid

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.