tesuji 135 Master Poster

Hi friend,

I am viewing your data dictionary and erm. Well, something seems to be wrong: some trouble with keys, composite keys, also the graphic of the erm emerges in a disordered manner. The relationships between orders and items and items and products, respectively should be redrawn. Maybe the disordered graphical elements are an result of my open office doc viewer (I don't use MS but Linux). I also suggest to post pdf files only (you may use freepdf to convert ms doc into pdf).

Btw, when is deadline, when should you hand in your results?

Ok, let's start to emend your design. There is a general rule to get the right foreign keys (and often the (composite) primary key): In an one-to-many relationship, the primary key of the entity from the one-side is moved into the entity what is located on the many-side, e.g. Between orders and items exists a one-to-many relationship, that is, orders is on the one-side and items on the many-side. Therefore, the primary key of orders must move into items, and there it becomes (at first) a foreign key.
Between products and items also exists an one-to-many relationship. Again, the primary key of products has to be moved into items. There it becomes a foreign key. Now that items has got two new attributes, finally we have to determine the primary key of items.

Do the move-in attributes order_ID and product_ID uniquely identify items ( you should keep in mind …

tesuji 135 Master Poster

hi a2008

if you divide two consecutive Fibonaccis, say F20 / F19 = 6765/4181 = 1.618033963, the ratio converges to the famous golden ratio (1 + sqrt(5))/2 = 1.61803398874989484820458683 . . .

krs,
cliff

tesuji 135 Master Poster

hi,

sure, MySQL now also offers some procedures, functions and triggers (of a kind) but one cannot compare that with Oracle's inimitable functionality nor you can seriously write PL/SQL programs using MySQL. I would suggest you download free Oracle express edition 10g which is also able to perform PL/SQL. Such a thing like Oracle clone is free PostgreSQL (UNIX and MS Windows) what also performs some PL/SQL.

krs,
cliff

tesuji 135 Master Poster

hi,

there is an extension to Chen's ERM what is called ISA relationship (is a .. ) for modelling generalization/specialization hierarchies, which also can be used to express inheritances. Maybe this will help you.

krs,
cliff

tesuji 135 Master Poster

hi mezo,

again, you should not solve your problem by adding 3 or even 8 columns to you product table for storing qty/units, if you also plan to run some queries again that table.

Scenario: you may have stored some 1000 products which have different numbers of qty/units. Now your boss ask you to show him a sql select list where for each product those qty/units should be listed together with product name. How to do that?

1. using my small core data model, where qty/unit data is stored in an extra table:
select m.itemNb, m.name, p.qty_per_unit from productunits p, masterdata m
where p.itemNb = m.itemNb

2. all qt/units stored together with master data in your product table:
no way to construct the SQL select because for each stored product you need to know
how many qty/unit columns exist.

krs,
cliff

tesuji 135 Master Poster

hi,
without where clause cross product of both tables will be computed, that is each row of income will be combined with each row of payments. To prevent this, you need a where clause like where i.fieldofincome = p.fieldofpayments, If you don't have such common fields you can't join both tables.

krs,
cliff

tesuji 135 Master Poster

hi mezo,

It depends on your datamodel where to store changing data. As for example merchandise management systems (also retail systems, ERP) usually distinguish between master data which remain almost unchangeable and transaction data which differs, for example such things like customers order data. If your customers can order a product in different quantities, say 5, 6, or 7 pieces / unit this information should be stored in an extra table, e.g. customers order item table together with item number, total price etc.

On the other hand you usually need a further table (and much more in real world applications) where you keep book which qty/unit can be assigned to a certain product, maybe also data to get total price.

So your core tables could look like these three:
masterdata(ItemNb#, Itemname),
Customerorderitems(orderNb#, ItemNb#, quantity, qty_per_unit, total_price),
productunits(ItemNb#, qty_per_unit#, price). (where # denotes primary key columns).

Maybe I can give you more help, if you show more details of your data model.

btw, it isn't a good idea to add three columns to your product table for recording the given three qty / unit because there would arise some serious problems when trying to create useful SQL queries or also when doing normalization.

krs,
cliff

tesuji 135 Master Poster

hi guy40az,

i am afraid this is not an easy task. Once i had programmed similar problems using plain c under real mode, what is rather outdated. Today i am using professional library for port and memory mapped IO on XP. Maybe you will succeed by using this interesting library: http://www.codeproject.com/KB/system/serial.aspx
good luck!

krs, cliff

tesuji 135 Master Poster

ofstream is for output, which can be combined with fstream::out | fstream::app // for append
but not with fstream::in | fstream::out

if you want to do both, use fstream.
you may have a look at http://www.daniweb.com/forums/thread6542.html

krs, cliff

tesuji 135 Master Poster

hi, below is listing 5.1 taken from second version of c++21d which you can found here:
http://www.angelfire.com/art2/ebooks/teachyourselfcplusplusin21days.pdf

All seems to be ok there. Maybe you have incompletely copied the example. functions can be overloaded, so it s possible that there is a second function FindArea what will meet your function call.

Listing 5.1. A function declaration and the definition and use of that
function.
1: // Listing 5.1 - demonstrates the use of function prototypes
2:
3: typedef unsigned short USHORT;
4: #include <iostream.h>
5: USHORT FindArea(USHORT length, USHORT width); //function
prototype
6:
7: int main()
8: {
9: USHORT lengthOfYard;
10: USHORT widthOfYard;
11: USHORT areaOfYard;
12:
13: cout << "\nHow wide is your yard? ";
14: cin >> widthOfYard;
15: cout << "\nHow long is your yard? ";
16: cin >> lengthOfYard;
17:
18: areaOfYard= FindArea(lengthOfYard,widthOfYard);
19:
20: cout << "\nYour yard is ";
21: cout << areaOfYard;
22: cout << " square feet\n\n";
23: return 0;
24: }
25:
26: USHORT FindArea(USHORT l, USHORT w)
27: {
28: return l * w;
29: }
Output: How wide is your yard? 100
How long is your yard? 200
Your yard is 20000 square feet
Analysis: The prototype for the FindArea() function is on line 5. Compare the prototype with the definition of the function on line 26. Note that the name, the return type, and the parameter types are the same. If they were different, a compiler error would have been generated. In fact, …
tesuji 135 Master Poster

hi gazoo,

if you want to check whether feb, 29 exists, then why not starting simpler than your code from line # 57 et seq. Maybe this way:

int year = 1800, month= 2, day = 29; // merely a test case

   if (leapyear(year))
   { cout << "yes, it's a bisextile" << endl;
   }
   else
   { cout << "no, not a bisextile" << endl;
      if ( month == 2 && day == 29 )
          cout << "sorry, no bisextile day in " << year << endl;
   }

krs, cliff

tesuji 135 Master Poster

Hi,

for testing I would suggest "Able was I ere I saw Elba", a perfect palindrome, once given by Napoleon I when he was embarking on his 100-day journey to that isle.

krs, cliff

tesuji 135 Master Poster

hi

"A leap year is never a good sheep year!"

also might be considered carefully, when solving highly sophisticated problems, what Pope Gregor really did when he introduced his new calendar based on "In omnibus solemnitatibus christianis non ignoramus paschale sacramentum esse principium, (sermo 47)":

In the Gregorian calendar, the current standard calendar in most of the world, most years whose division by 4 equals an integer are leap years. In one leap year, the month of February has 29 days instead of 28. Adding an extra day to the calendar every four years compensates for the fact that a solar year is almost 6 hours longer than 365 days.

However, some exceptions to this rule are required since the duration of a solar year is slightly less than 365.25 days. Years which are evenly divisible by 100 are not leap years, unless they are also evenly divisible by 400, in which case they are leap years. For example, 1600 and 2000 were leap years, but 1700, 1800 and 1900 were not. Similarly, 2100, 2200, 2300, 2500, 2600, 2700, 2900, and 3000 will not be leap years, but 2400 and 2800 will be. By this rule, the average number of days per year will be 365 + 1/4 − 1/100 + 1/400 = 365.2425, which is 365 days, 5 hours, 49 minutes, and 12 seconds.

The Gregorian calendar was designed to keep the vernal equinox on or close to March 21, so that the date …

tesuji 135 Master Poster

omg sky diploma,

your leap-year rule is from the Julian calendar, which was superseded anno domini 1581 by Pope Gregor's new Gregorian calendar. View #22 where this very new rule is given !

krs, cilff

tesuji 135 Master Poster

hi

i ve just checked your erd und dd:

1. items must have primary key, e.g. foreign key order_id + item_nb (1,2,3..)
item_nb is necessary, if a certain order contains more then 1 item.

2. relationship between suppliers and products should be many-to-many, that is a certain product could be delivered by many suppliers and a certain suppliers could deliver many products.

3. data type of qty should be integer.

4. I would drop entity warehouse, as already stated.


further on, your erd seems to be ok, especially all crowfeet are placed correctly.

brs, cliff

Dear tesuji

Thank you for your reply to my post.

Please find attached my ERD and Data Dictionary I would be very grateful if you could correct any Errors I have made especially with Primary, Foreign and composed key.

Thanks for your help

BTW thanks for pointing out the website.

HB25

tesuji 135 Master Poster

hi,

finally you also should implement the correct algorithm to computing leap year:

int LeapYear(int year)
{ return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0 ? 1 : 0; }

brs, cliff

tesuji 135 Master Poster

hi,
if you design an entity relationship model (ERM) there are only entities and relationships. There aren't any "tables" there. Once you might map your ERM into relational model, which consists of tables (relations) only.

Your shown relationship ' (ONE) Warehouse-> could have many -> orders' expresses the trivial fact that a warehouse has many orders. It is already clear that those orders belong to a sole warehouse because your given task is headlined by "Design a ERM datamodel for a warehouse". Thus, we should omit the entity warehouse.

Your warehouse datamodel may have these entities: products, customers, orders, orderlines, suppliers, stock (to record products on stock)

where the following relationships can be found:

customers ------ one-to-many ----<- orders

orders ----- one-to-many -----<- orderlines

products ----- one-to-many ----<- orderlines

products ->---- many-to-many ----<- suppliers

products ----- one-to-many ----<- Stock

If you are to design the relationship between suppliers and products more detailed in an analogous way to customers/orders, you have to adopt similar entities such us purchase and purchase_orderline.

You also may have a look at http://www.databaseanswers.org/data_models/index.htm.

brs, cliff

tesuji 135 Master Poster

hi,

storing some data (physically) in 900 different tables seems to be a rather bad idea, because you would have union them firstly to draw any useful information from them. Aside from the fact that handling 900 different tables when adding actual data every week isn't that easy-going. I would like to suggest you that give a meaningful example with concrete data, something like this:

week, clPrice, volume, marketC, PE(?), Company, ...
1, 100, 1000, 30%, ??, INTG
2, ....
...
10, ....

You should add further missing but important attributes to that big table. Don't worry about decomposition into smaller tables; this 2nd step is quite simple if one has broadly understand your data. To speed up processing your data you can add some indexes.
btw, 900x52x16 = 748800 records isn't that much data for any RDBMS, even MS Access will cope with this task.

brs, cliff

tesuji 135 Master Poster

hi djclipz,

one cannot state anything about your normalisation, if you do not tell precisely of which attributes your relations consist of. As for "suich as employee id, fname, sname, sex, houseno, street name etc etc " what is etc etc? It might be helpful for yourself if you list some functional dependencies.

brs, cliff

tesuji 135 Master Poster

Hi there everyone,

I've just started with Ubuntu 7.10 and KDevelop 3.5.8 (just installed, true greenhorn to Ubuntu) .

First, I created this hello-world program:

#include <cstdio>
int main() { printf("Hello World\n"); return 0;}

with gedit, compiling and linking it with g++ -o hello hello.cpp. Running it with ./hello worked fine and "Hello World" was shown on console window.

Now I tried out this task in KDevelop 3.5.8. But serious error occured:

/home/dev/hello: Permission denied
*** Exited with status: 126 ***

Does KDevelop need special permissions on folder /home/dev/hello? On the other hand, gedit and g++ also wrote files to same folder and executing ./hello worked correctly.

Can anybody help me to solve this problem? I really appreciate any help of you.

Best regards, tesuji

I should note that I installed the complete KDevelop system on gnome-based Ubuntu 7.10. I have also installed auto make tool.

tesuji 135 Master Poster

hi,
we all should consider: Edsger Wybe Dijkstra famous "Go To Statement Considered Harmful". To be found at: ACM (copy: http://www.cs.utexas.edu/users/EWD/ewd02xx/EWD215.PDF)

brs, tesu