473,395 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

database design

bilibytes
128 100+
hi,

I am trying to figure out what DB design to have for my application.

ok lets imagine the following enterprise: TheBigBigEnterprise Inc. => TBBE

TBBE is an international enterprise(with offices in 1000 cities) that has LOTS of employees. The employees are in charge of maintaining the commercial relations with partner enterprises in their city.
That is why, the employees invest their time in visiting these other enterprises to see how wealthy they are, and then they rate the evolution. (at each meeting TBBE employees will make a rating for the period between previous meeting and this one)

These employees have access to a website where they have their personal space.

That space is compound of a big calendar, which is used as a "to do" list.
This calendar shows the actual month, and in each day, are listed the enterprises that TBBE employees have to visit that day.

So TBBE DataBase has all the names of its partner enterprises. These partners have a space in the web, where they can request for a meeting with TBBE employees.
Only partner enterprises can ask for a meeting, that is to say they have to login first..., TBBE has also in its DataBase the partners name, password, description, logo...
When the partner enterprise has requested for a meeting, the TBBE employees can see on their calendar the partner enterprise's name and logo in each day a meeting has been requested.

the Director tells afterwards which employee will go to what meeting,
the employe will then go to the calendar and click on the day his boss told him to go. This will open another page with all the meetings for that day. And now he has to find the name of the partner enterprise he has to meet. difficult task...

The bad thing in all this, is that, these employees are a bit fed up seeing in their calendar, (and after that in the final selection page) the names of all the partners from all other cities TBBE's international employees have meeting with.
they would prefer just being shown the meetings in their own city. It would make the calendar a bit clearer. and their life too.



->how would the DB have to look like?

ok so what i have thought in my firs aproach is:

0. Employees
-all employees information

Expand|Select|Wrap|Line Numbers
  1. employee_id
  2. name
  3. pass...

1. Location
-there are repeated city names in the world, so also store the country:

Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE `locations` (
  2.   `location_id` int(10) unsigned NOT NULL auto_increment,
  3.   `country` varchar(40) NOT NULL default '',
  4.   `city` varchar(40) NOT NULL default '',
  5.   PRIMARY KEY  (`loc_id`)
  6. )

2.Partners
-assuming partners may have one name per city (in the case they are an international company, they may have the same name in different cities) so pair the name with the location_id

Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE `partners` (
  2.   `partner_id` int(10) unsigned NOT NULL auto_increment,
  3.   `location_id` int(10) unsigned NOT NULL default '0',
  4.   `partner_name` varchar(255) NOT NULL default '',
  5.   `partner_pass` varchar(255) NOT NULL default '',
  6.   `partner_description` text NOT NULL,
  7.   `logo_id` int(11) NOT NULL default '0',
  8.   PRIMARY KEY  (`pre_id`)
  9. )

3.Logos
-the images are stored separately and associated to the partner with the logo_id (should i store the partner_id in images table or the logo_id in partners table?)

Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE `images` (
  2.   `logo_id` int(10) unsigned NOT NULL auto_increment,
  3.   `img_type` varchar(50) NOT NULL default '',
  4.   `image` longblob NOT NULL,
  5.   `img_size` bigint(20) NOT NULL default '0',
  6.   `img_name` varchar(255) NOT NULL default '',
  7.   `img_date` datetime NOT NULL default '0000-00-00 00:00:00',
  8.   PRIMARY KEY  (`img_id`)
  9. )

4.Calendar
-number_employees_at_meeting: for each meeting, the Director can decide to send as many employees as he wants (this is the number of employes for the specified meeting...)
-In the calendar, will also figure, the overall rating that TBBE employees have been giving of partners performances from previous meetings (since they started partnership: shall i make a specific table rates or i should store the cumulated rate with the number of rates in the calendar table, in order to, then, divide the cumulated_rate by the number of rates(->average rate) )

Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE `calendar` (
  2.   `calendar_id` int(10) unsigned NOT NULL auto_increment,
  3.   `date` datetime NOT NULL default '0000-00-00 00:00:00',
  4.   `partner_id` int(10) unsigned NOT NULL default '0',
  5.   `number_employees_at_meeting` tinyint(5) unsigned NOT NULL default '0',
  6.   `partner_rate_cum` int(10) unsigned NOT NULL default '0',
  7.   `partner_rate_times` int(10) unsigned NOT NULL default '0',
  8.   PRIMARY KEY  (`cal_id`)
  9. )

5.Employee at Meeting
- the boss has to be able to see which of his employees he sent to what meeting, when he selects the date and partner in the calendar.
(should i put all this information in the same table as calendar or is it well done separate like this?)

Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE `employee_meeting` (
  2.   `employee_meeting_id` int(10) unsigned NOT NULL auto_increment,
  3.   `calendar_id` int(10) unsigned NOT NULL default '0',
  4.   `employee_id` int(10) unsigned NOT NULL default '0',
  5.   PRIMARY KEY  (`ppd_id`)
  6. )

ok, so if the boss or any one in the company wants to see which employees were sent to the specified meeting, wouldn't there be too many queries?

Expand|Select|Wrap|Line Numbers
  1. public function list_employees_for_meeting($location, $date, $partner){
  2.  
  3.     //$location = array(country => usa, city => baltimore);
  4.     /*1 Get the location id*/
  5.         $sql = "SELECT location_id FROM locations WHERE country = $location[country] AND city= $location[city]";
  6.     //assuming i get location_id in $location_id variable 
  7.  
  8.     /*2 Get the partner's id */
  9.         $sql = "SELECT partner_id FROM partners WHERE partner_name = '$partner' AND location_id = '$location_id'";
  10.     //assuming i get the partner_id in $partner_id variable
  11.  
  12.     /*3 Get the calendar_id */ 
  13.         $sql = "SELECT calendar_id FROM calendar WHERE partner_id = $partner_id AND date = '$date' ";
  14.  
  15.     /*4 Get employees ids*/
  16.         $sql = "SELECT employee_id FROM employee_meeting WHERE calendar_id = $calendar_id";
  17.  
  18.     /*GOT MY LIST OF EMPLOYEES*/
  19. }

aren't that too many queries for a simple list?
lets say 100 millions of employees request this information per day, wouldn't it break the server?? if this was done like this, should i contract a big big hosting plan what is the weight of this type of queries?
is there a better way to perform this:
or by redesigning the database or by making a different query or by I don't know?

congratulation if you red this far. :)

Please you experts help me.

Thank you very very very much,

Bili
Nov 2 '08 #1
0 2111

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Rushikesh | last post by:
I am designing a WEB BASED Accounting Software with ASP and SQL Server. For this I need some help for the Database design. My design is as follows. I)User table: User_id, UserName..... Users...
5
by: Don Vaillancourt | last post by:
Hello all, Over the years as I design more database schemas the more I come up with patterns in database design. The more patterns I recognize the more I want to try to design some kind of...
1
by: Lane Beneke | last post by:
All, New to the list and a relative newbie to PostgreSQL. Please forgive stupid questions. Designing an application server for a work order processing (et al) database. I have a good handle...
5
by: trynittee | last post by:
Hello, It's been a while since I've posted. I am an intermediate user of Access. I can read simple VB code, have done complex queries, comfortable with event procedures, designing forms and...
12
by: nyathancha | last post by:
Hi, I have a question regarding best practices in database design. In a relational database, is it wise/necessary to sometimes create tables that are not related to other tables through a...
3
by: vicky | last post by:
Hi All, Can u please suggest me some books for relational database design or database modelling(Knowledgeable yet simple) i.e. from which we could learn database relationships(one to many,many to...
0
by: Laurynn | last post by:
# (ebook - pdf) - programming - mysql - php database applicati # (Ebook - Pdf)Learnkey How To Design A Database - Sql And Crystal Report # (ebook-pdf) E F Codd - Extending the Database Relational...
1
by: abhijitbkulkarni | last post by:
Hello, I am designing a .NET database application that uses 3 tier architecture. Starting initially, this application will be desktop application but I will convert it into a website later but...
0
by: sam | last post by:
Hi, Hope you are doing well !!!! One of our clients is looking to augment their team with “Database Architect – DB2" please find below the details and respond with
2
by: programmerx101 | last post by:
Ok, I'm looking for expert advice on this one. I have a database which keeps going into read_only mode. Sometimes it goes into read_only / single user mode. Once it was taken offline completely....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.