FacebookTwitter
Hatrack River Forum   
my profile login | search | faq | forum home

  next oldest topic   next newest topic
» Hatrack River Forum » Active Forums » Books, Films, Food and Culture » Because I'm an evil person

   
Author Topic: Because I'm an evil person
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
I'm going to inflict an ER diagram and a relational model on you.

http://homepage.mac.com/fugu13/ercard.pdf

http://homepage.mac.com/fugu13/db.pdf

Why? Because I'm an evil person, of course.

Really no other reason. I just thought everyone would love to see the gooey wonderfulness from my Informatics "Final Project". What's even scarier is that because I'm so used to thinking in databases, creating both of those documents took less than an hour (and a lot of that was making them look pretty . . . ).

Given I don't think its going to take more than five minutes to grade for the AIs, and I didn't want it to be so hardly seen after I spent all that effort to make it look nice, I thought I might inflict it on all of you [Wink] [Razz] .

Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Vána
Member
Member # 6593

 - posted      Profile for Vána   Email Vána         Edit/Delete Post 
They're very pretty. *patpat*
Posts: 3214 | Registered: Apr 2002  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
Thank you.
Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Mike
Member
Member # 55

 - posted      Profile for Mike   Email Mike         Edit/Delete Post 
Lemme guess, OmniGraffle?
Posts: 1810 | Registered: Jan 1999  |  IP: Logged | Report this post to a Moderator
Dagonee
Member
Member # 5818

 - posted      Profile for Dagonee           Edit/Delete Post 
This is how I think in my head. Big help in law school, actually. What program did you use?

The only things I'd mark you down on are using SSN for a primary key [No No] , having separate tables for managers and servers, and using Name for a primary key on OrderItem. [Smile]

I'd probably also use a generated key for Order, but I wouldn't mark you down for it.

Dagonee

[ December 10, 2004, 12:39 PM: Message edited by: Dagonee ]

Posts: 26071 | Registered: Oct 2003  |  IP: Logged | Report this post to a Moderator
Altáriël of Dorthonion
Member
Member # 6473

 - posted      Profile for Altáriël of Dorthonion   Email Altáriël of Dorthonion         Edit/Delete Post 
You evil person you!
Posts: 3389 | Registered: Apr 2004  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
Heh, I actually tend to agree on those things, but this was a group project, and I have to do two things: make it understandable to my group members and fulfill the requirements, which were badly written.

I don't feel bad about using the SSN as a primary key, though, because this is a small "Mom N Pop" restaurant (the name in the problem is "Mom N Pop's Restaurant").

Yes, it was created with Omnigraffle, which is excellent for these sorts of things.

Name has to be part of the primary key on orderitem because its the primary key on item, so to uniquely determine an orderitem (in a mathematically meaningful way [Wink] ) you need it. The reason its a primary key on item is that due to how people need to order stuff, any name must be unique. You can't order the "Strawberry Tart with ItemID #52" instead of the "Strawberry Tart with ItemID #236" -- there's only the Strawberry Tart.

The separate tables for managers and servers is just a group understanding thing, though it is imaginable the information in the real world for managers and servers would be orthogonal enough to justify separate tables. However, what I'd normally do is make them both IsA employee on the ER model, then have an employee table with a manager? field.

Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Altáriël of Dorthonion
Member
Member # 6473

 - posted      Profile for Altáriël of Dorthonion   Email Altáriël of Dorthonion         Edit/Delete Post 
bad squishy! bad!
Posts: 3389 | Registered: Apr 2004  |  IP: Logged | Report this post to a Moderator
Scott R
Member
Member # 567

 - posted      Profile for Scott R   Email Scott R         Edit/Delete Post 
My hatred for you is surpassed only by my apathy.
Posts: 14554 | Registered: Dec 1999  |  IP: Logged | Report this post to a Moderator
Dagonee
Member
Member # 5818

 - posted      Profile for Dagonee           Edit/Delete Post 
Oops, I meant Item, not OrderItem when referring to name as the primary key. The big problem there is if the name changes (that's only one of the problems w/ SSN - yes, it does happen), then old records either have to be updated or orphaned.

SSN has privacy issues in addition to the potential for changing. Having it in one field allows that field to be restricted. In DBMSs without field-level access control, we've gone so far as to move SSN to separate tables. But then, we worked for the government, with much stricter rules on privacy issues.

And badly written requirements are the bane of all designers. [Smile]

Dagonee

Posts: 26071 | Registered: Oct 2003  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
(((((Scott)))))

In this case, if the name changes, its a new item.

*nods* yeah, I can see that on SSN, in this case we're sort of like blockbuster, where any employee can see the full credit card numbers of any credit card used to sign up for an account that has been used at that store [Wink] . In fact, I may change that, if I feel like it.

Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Mike
Member
Member # 55

 - posted      Profile for Mike   Email Mike         Edit/Delete Post 
Huh. Databases are completely foreign to me, and I majored in computer science (and math). One of these days I'll learn how to use them.
Posts: 1810 | Registered: Jan 1999  |  IP: Logged | Report this post to a Moderator
Dagonee
Member
Member # 5818

 - posted      Profile for Dagonee           Edit/Delete Post 
Damn, remind me to cancel my Blockbuster accounts.
Posts: 26071 | Registered: Oct 2003  |  IP: Logged | Report this post to a Moderator
Sara Sasse
Member
Member # 6804

 - posted      Profile for Sara Sasse   Email Sara Sasse         Edit/Delete Post 
fugu, would you lose all respect for me if I said I'm afraid to look?

I don't understand many things, and I have a tendency to screw up my computer in weird ways, so anxiety is preventing me from clicking. (I've tried thrice.)

But I'm very impressed from the description. [Smile]

Posts: 2919 | Registered: Aug 2004  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
Oh, you can do several things to avoid it.

1) sign up without a credit card.

2) ask them to remove the credit card information from your account.

3) sign up with a credit card, but request they not write down the number, you'll just rent less for the first month.

Oh, and if ask them to cancel it, make sure they do it. They might do nothing (because from their perspective, if you don't come in the account doesn't get used, so what's the point of canceling it?)

Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Corwin
Member
Member # 5705

 - posted      Profile for Corwin           Edit/Delete Post 
Sara, don't worry, they're just some innocent looking diagrams! The names sound more complicated than the actual things! Of course, it might have something to do with the fact that I too study Computer Science... Hmm...
Posts: 4519 | Registered: Sep 2003  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
All those are is PDF's, and small ones at that, they can't screw up your computer. However, if nothing's happening, you may not have a PDF reader installed or correctly configured (most likely the former).
Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
Mike: Databases are just set theory, pretty much.
Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Sara Sasse
Member
Member # 6804

 - posted      Profile for Sara Sasse   Email Sara Sasse         Edit/Delete Post 
Oh, fugu, they are very pretty! [Smile]
Posts: 2919 | Registered: Aug 2004  |  IP: Logged | Report this post to a Moderator
Corwin
Member
Member # 5705

 - posted      Profile for Corwin           Edit/Delete Post 
I think this is the first time I hear someone say diagrams are pretty!

[ROFL]

Posts: 4519 | Registered: Sep 2003  |  IP: Logged | Report this post to a Moderator
Mike
Member
Member # 55

 - posted      Profile for Mike   Email Mike         Edit/Delete Post 
fugu: does the axiom of choice matter? [Wink]
Posts: 1810 | Registered: Jan 1999  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
You know, I'm not sure . . . I'd guess yes, but that's just intuition.
Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Dagonee
Member
Member # 5818

 - posted      Profile for Dagonee           Edit/Delete Post 
A good ERD is a thing of beauty. [Smile]
Posts: 26071 | Registered: Oct 2003  |  IP: Logged | Report this post to a Moderator
MrSquicky
Member
Member # 1802

 - posted      Profile for MrSquicky   Email MrSquicky         Edit/Delete Post 
I'd agree with Dags here. I'd combine the server and manager table into one employee table with either a flag or foreign keyed type field, which would also let you consolidate the different shift tables. If you can only have one item with a name, just drop an unique index on that field and use an autogen'd id. That'll give you the ability to make item name alterations based on things like American foreign policy (eg. French fries to Freedom fries) and relieve you of the admittedly slight performance/storage hit you take for using a non integer id.

Hey, if we're being evil, I need to get my piece too.

edit: [Kung-Fu announcer voice]Enter the Fifth Normal Form[/Kung-Fu announcer voice]

Idle question, does anyone really trifle with the 4th or 5th normal forms? My db-fu is strong, but they frighten me (or rather seem largely unnecessary).

[ December 10, 2004, 04:09 PM: Message edited by: MrSquicky ]

Posts: 10177 | Registered: Apr 2001  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
You mean the joining tables? Those're just implementation details, and taken care of by any good OR mapping software automatically.

And anyways, as I said that's likely what I'd do myself absent group members [Wink] .

As this class largely focused on (very primitive) database theory, the name as primary key thing is definitely staying, as its more "theorylicious". Primary keys independent of the data are considered icky [Wink] .

As for fourth and fifth normal form, I think you'll find them used mainly in data warehousing and KDD processes, as normalizations are particularly important there.

Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Dagonee
Member
Member # 5818

 - posted      Profile for Dagonee           Edit/Delete Post 
quote:
Primary keys independent of the data are considered icky
Which has always proven to me that theorists don't design enough systems and maintain them in the real world. [Big Grin]

I never paid much attention to 4NF or 5NF. THey usually happened anyway, and really amount to simply thinking out what you want to be able to represent.

Dagonee

Posts: 26071 | Registered: Oct 2003  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
Dagonee, think of it as naive implementation for the sake of learning, sort of like how physics students calculate all those trajectories absent air resistance, or assume instantaneous turnarounds, or assume a point cow. So many people are taught to just use a separate, automatically incrementing field as a primary key that they do it everywhere, even with (for instance), the shifts table here, where its preferable to use start and duration (since whenever those are the same its the same shift, and whenever those are different its a different shift).

Many people are taught the autonum way, and then never bother with anything different because that's "easy". This is the first time most of the students in this class are seeing databases, and emphasizing the importance of meaningful PKs will result in better database design in the long run, I feel.

Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Raia
Member
Member # 4700

 - posted      Profile for Raia   Email Raia         Edit/Delete Post 
Because *I* am an evil person...

I just won't look at them. [Razz]

Posts: 7877 | Registered: Feb 2003  |  IP: Logged | Report this post to a Moderator
TMedina
Member
Member # 6649

 - posted      Profile for TMedina   Email TMedina         Edit/Delete Post 
I'll second the "joint employee table" idea - you can just assign an "employee_ID" which is shorter and easier to use than a SSN which, while fulfilling the requirements of a Primary Key, is just a pain to type in.

Reducing your table count is always a good thing.

I'm not sure why you have so many primary keys in the Server_Shift table - in fact, the design seems to be pretty PK happy.

All of which reminds me, I need to brush up on my ERDs.

-Trevor

Posts: 5413 | Registered: Jun 2004  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
There is only one PK on any given table. That PK can, however, be over multiple columns.

The SSN is going to be in the database structure somewhere -- that's important information if nothing else for tax purposes. As for it being a pain to type in . . . this is a project intended to simulate a small restaurant. Typing in a nine digit number for maybe a couple dozen employees is not a big deal.

Also, reducing your table count is not always a good thing, it is often better to factor something out than to make a huge overly complex table.

Any design should be "PK happy". In fact, there should be indexes and constraints and such all over the freakin' place in most well-designed databases. This doesn't mean index everything -- but if you're going to be doing any sort of search or join on a column or group of columns, an index will speed things up by orders of magnitude.

Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Dagonee
Member
Member # 5818

 - posted      Profile for Dagonee           Edit/Delete Post 
quote:
Dagonee, think of it as naive implementation for the sake of learning, sort of like how physics students calculate all those trajectories absent air resistance, or assume instantaneous turnarounds, or assume a point cow.
Absolutely. Point cows are wildly impractical - low meat yield.

quote:
Reducing your table count is always a good thing.
It's no so much reducing table count - normalization usually increases table count by a lot. It's more about treating like entities alike.

Dagonee

Posts: 26071 | Registered: Oct 2003  |  IP: Logged | Report this post to a Moderator
Mike
Member
Member # 55

 - posted      Profile for Mike   Email Mike         Edit/Delete Post 
Consider a Spherical Cow.
Posts: 1810 | Registered: Jan 1999  |  IP: Logged | Report this post to a Moderator
   

   Close Topic   Feature Topic   Move Topic   Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:


Contact Us | Hatrack River Home Page

Copyright © 2008 Hatrack River Enterprises Inc. All rights reserved.
Reproduction in whole or in part without permission is prohibited.


Powered by Infopop Corporation
UBB.classic™ 6.7.2