« first day (1807 days earlier)      last day (851 days later) » 

7:19 AM
question related to database if any one could help me
designing database structure for stock management with maintaining history of each date
want report that on which day how much stock was?
 
7:58 AM
Hi @TehShrike Hi all
Thx for your previous advice concerning "time" fields
Since, I retrieved data from a "bad" file and got some "timestamps" as 3 columns (excel file) like "year" (int), "month" (int), "day" (int). I'd like to convert these values into a "date" field in db... So I can do comparisons on the field value, actually I'd have to compare 3 columns values to 3 other with kinds of "formulas" to make it effective, which is a bad way doing this imo
 
8:27 AM
Got it for insert, but got to compare this way :
It's a kind of "visits" database, with records like : "id, addressid, date, type". Type is "firstvisit,standard,end". End visit is supposed to make the next visit not possible and the address inactive. But sometimes a new "firstvisit" is done later and the address is coming active again. So what I'm looking for is all "inactive" addresses on the last visit record
(idk if i'm clear but query should look like this : )
SELECT id FROM visits WHERE (type = 'end') AND (date = (SELECT MAX(date) FROM visits WHERE id = /*HERE IS MY PROB*/))
 
hello
 
hi
 
can someone check my homework
:O
 
^^
"Ask your question, and then hang around a while to see if an expert looks back at their screen and answers it!"
 
oh
:D
I wanted to know if my entities/attributes/relationships/cardinalities were okay
before I go ahead and use Visio to make the ERD
 
8:47 AM
well, doesnt look that bad, you have no pk's on instrument & category
 
oh yeah, for instrument it would be Instrument_Name as the PK and then category would have Instrument_Type as PK and instrument_name as FK
?
 
well personnaly i would not use "name" (text/string) as a pk but just a numeric field (serial), but i'm not pro
 
i couldnt think of a numeric field as PK for instrument or category, do you think of one?
 
You may wait for @TehShrike to come back to get some good answer instead of suggestion... Well I'm thinkin just about an "ID" field you know...
 
Instrument_ID
 
8:53 AM
ye
 
which would be pk for instrument but fk for category :P
yay i think im gonna make the erd now
can you have more than one FK in a relationship?
like, Instrument_ID and Instrument_Name would both be FK?
is Center_Name not a good idea for a primary key?
I'm trying to think of a numeric field
 
9:13 AM
Is this a right chatroom to ask question related to DB2?
 
 
6 hours later…
3:00 PM
@SagarNaliyapara Two ways you could do it. You could make each change to your inventory be represented by an immutable document with a timestamp
and then to find the quantity on a particular day, you can add up all "increase quantity" and subtract all 'decrease quantity" documents before that date to find out what the quantity was
Or, you can run daily batch jobs that record the quantities at a particular time.
@Hello That schema implies that concerts can only have a single musician
And it looks like instruments and categories don't have any relationship to concerts or musicians
I'd recommend using auto-increment IDs for the primary keys of all values. The unique names are what you'd call a "candidate key"
@ChamilaWijayarathna as right as any of 'em, I suppose
@Julo0sS what's the definition of "inactive"?
Can you paste your current schema (SHOW CREATE TABLE visits) again?
 
 
8 hours later…
10:53 PM
hi
 

« first day (1807 days earlier)      last day (851 days later) »