473,756 Members | 3,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Guidence on database design

34 New Member
My background VB6 and some SQL - just remember enough to be dangerous.

First time actually using Access to access data. (eg forms and reports)

Using Access 2000

Need some guidence with a database i'm designing on tracking jobs and their shipping dates

I have Table1 with Fields: JobID (PK), SubDivID (PK), Type, ShipID (FK), InvoiceID (FK)

I have Table2 with Fields: ShipID (PK), ShipFloor (PK) Shipper, ShipDate

I made a form that when I enter in JobID and SubDivID it creates the ShipID and InvoiceID from both the JobID & SubDivID and adds a suffex (eg JobID L64; SubDivID PT; becomes L64PT-shp for ShipID)

First question: Is this a good design practice to do this.

Second question: Is this a good way to code what I did: (should i use a command button? other suggestions?) It works but think it can have flaws.


Expand|Select|Wrap|Line Numbers
  1. Private Sub JobID_Change()
  2.     strJobID = Me.JobID.Text
  3.     intJobIDb = 1
  4.     intJobIDi = 1
  5.     intJobIDs = 1
  6. End Sub
  7.  
  8. Private Sub ShipID_GotFocus()
  9.     If intJobIDs = 1 And intSubDIDs = 1 Then
  10.         Me.ShipID.Text = strJobID + strSubDivID & "-shp"
  11.         intJobIDs = 0
  12.         intSubDIDs = 0
  13.     End If
  14. End Sub
  15.  
  16. Private Sub SubDivID_Change()
  17.     intChange = 1
  18. End Sub
  19.  
  20. Private Sub SubDivID_LostFocus()
  21.     If intChange = 1 Then
  22.         strSubDivID = Me.SubDivID.Text
  23.         intSubDIDb = 1
  24.         intSubDIDi = 1
  25.         intSubDIDs = 1
  26.         intChange = 0
  27.     End If
  28.  
  29. End Sub
Third question: Can I now add a record in Table2 with the created ShipID. What is the best way to do this?

Thanks for the Help,
Nov 20 '06 #1
8 1568
MMcCarthy
14,534 Recognized Expert Moderator MVP
My background VB6 and some SQL - just remember enough to be dangerous.

First time actually using Access to access data. (eg forms and reports)

Using Access 2000

Need some guidence with a database i'm designing on tracking jobs and their shipping dates

I have Table1 with Fields: JobID (PK), SubDivID (PK), Type, ShipID (FK), InvoiceID (FK)

I have Table2 with Fields: ShipID (PK), ShipFloor (PK) Shipper, ShipDate
I'm just going to deal with the first part first. As it will affect the other questions.

ShipID and ShipFloor as a joint primary key in Table2 is not a good idea unless it's done to solve a many to many relationship. You cannot obtain a unique record using ShipID as the foreign key in Table1 you would need to create a relationship to both ShipID and ShipFloor.

I'm assuming the only reason you've don this is that ShipID in table2 is not unique on its own. Solution is to create a new field XXXID (Type Autonumber) and set it as the primary key and use it as the foreign key in Table 1.
Nov 20 '06 #2
Tetelestai
34 New Member
I'm just going to deal with the first part first. As it will affect the other questions.

ShipID and ShipFloor as a joint primary key in Table2 is not a good idea unless it's done to solve a many to many relationship. You cannot obtain a unique record using ShipID as the foreign key in Table1 you would need to create a relationship to both ShipID and ShipFloor.

I'm assuming the only reason you've don this is that ShipID in table2 is not unique on its own. Solution is to create a new field XXXID (Type Autonumber) and set it as the primary key and use it as the foreign key in Table 1.

Thanks for the reply...

I think I'm forming this database wrong... I have the shipping info between the parts of a job

A job (Order of wall panels for a house) may have many floors but one floor belongs to only one job. Each floor can be shipped individually.

I have a tendency to avoid the autonumber cause I believe one of my VB instructors advised against it's use. Is there any concern with autonumber?

Thanks again
Nov 21 '06 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
I will address the issues separately.

I have a tendency to avoid the autonumber cause I believe one of my VB instructors advised against it's use. Is there any concern with autonumber?
There may be issues with straight VB but with Access it's almost always a necessity. I'm not sure what your instructors problem with it was but think of primary keys this way.

If you have a natural numeric value that is unique to records your table then this can be used as a primary key without any problems.

If you have a natural alpha/numeric value that is unique to records your table then this can be used as a primary key but it limits functionality as you cannot for example use Max(ID_Field) to get the last entry.

If you have two values that combined make up a unique record you can create a double primary key based on both values. This can cause problems because both values have to be referenced when a used as a foreign key in another table.

There are two ways to create your own primary key.
1. The system Autonumber facility. Access generates the next number based on the last number it issued to this table plus one. Your instructor may have been talking about the numbers jumping sequence because records have been deleted. This is easily resolved by regularly running a compact and repair on your database which should be done for other reasons also.

2. You can create a unique ID using VBA code behind the data entry form. This would mean that records could only be generated using this form. If you want this option I can provide some sample code.

Although, you can create other indexes in a table remember that the Primary Key is the main index and is also used to create relationships between the tables.
Nov 21 '06 #4
MMcCarthy
14,534 Recognized Expert Moderator MVP

I think I'm forming this database wrong... I have the shipping info between the parts of a job

A job (Order of wall panels for a house) may have many floors but one floor belongs to only one job. Each floor can be shipped individually.
Is this your setup:

Orders have Many Jobs and Jobs have only one order.

This is a many to one relationship

Table Jobs should have a foreign key referencing the OrderID (PK) of Table Orders.

There is one floor per job and therefore this info can be in the Job table

There is one and only one shipment per job
or
A shipment can be made up of one or many jobs

Which is true?
Nov 21 '06 #5
Tetelestai
34 New Member
Is this your setup:

Orders have Many Jobs and Jobs have only one order.

This is a many to one relationship

Table Jobs should have a foreign key referencing the OrderID (PK) of Table Orders.

There is one floor per job and therefore this info can be in the Job table

There is one and only one shipment per job
or
A shipment can be made up of one or many jobs

Which is true?
I would say an order is the same as a job - A start order has only one job

a job could have many floors

each floor may be shipped at different times
Nov 21 '06 #6
MMcCarthy
14,534 Recognized Expert Moderator MVP
I would say an order is the same as a job - A start order has only one job
So you should have an orders table containing details about jobs.

a job could have many floors
So you should have an orders_details table with a new record for each floor and a foreign key field to the OrderID (PK) of the orders table and a foreign key field to the ShipID (PK) of the shipments table (see below) .

each floor may be shipped at different times
So you have a shipments table with details of shipments. See above.

Now you have a relationship orders --> orders_details --> shipments

Starting to get the picture?

Mary
Nov 21 '06 #7
Tetelestai
34 New Member
So you should have an orders table containing details about jobs.



So you should have an orders_details table with a new record for each floor and a foreign key field to the OrderID (PK) of the orders table and a foreign key field to the ShipID (PK) of the shipments table (see below) .



So you have a shipments table with details of shipments. See above.

Now you have a relationship orders --> orders_details --> shipments

Starting to get the picture?

Mary
Starting, I will have to playaround with this for abit (might be awhile, other work calling)

Thanks
Nov 21 '06 #8
MMcCarthy
14,534 Recognized Expert Moderator MVP
Starting, I will have to playaround with this for abit (might be awhile, other work calling)

Thanks
No problem

It's important to get your head around this before proceding further.

Take your time.
Nov 21 '06 #9

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

Similar topics

1
1503
by: Jeff Uchtman | last post by:
Query in ASP against a MS SQL DB. <% Dim Sql Dim Conn Dim totalCount Dim rsCount Dim rsACount Dim PetACount Dim rsBCount
3
4515
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 (e.g. John Smith) Each User would contain a following Group of tables a)Customers
5
674
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 generic design patterns that can be used and shared amongst many sub-schemas. For example, the grouping of entities. I may have the following tables: employee, product and client. These tables have no direct relationship with each other. But...
3
2422
by: solomon_13000 | last post by:
> Wonthaggi Civic Theatre 'WCT' Case Study > > The town of Wonthaggi has a theatre which is owned and > operated by the local council, it is called the > Wonthaggi Civic Theatre (WCT) and a wide variety of > shows are presented there, for example plays, music > and talks. The management has decided to build a > computer system for WCT to handle ticket sales, keep > track of the work done by staff and record all shows > presented in the...
1
3494
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 on sequences, referencial integrity, views, & the basics. What books/documentation would you recommend to learn more about...
5
9629
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 reports. I have not worked with a split database before. And now I am. The front-end database seems to be called .mdb not .mde. Does this
3
2486
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 one etc.....),building ER diagrams,proper usage of ER diagrams in our database(Primary key foreign key relations),designing small modules,relating tables and everything that relates about database design....Coz I think database design is the...
0
733
by: qasimkhan85 | last post by:
hi there. I ahev a module in my project to attcah a mobile phone with computer.then sms recieved on mobile shoud be displayed on computer.after some calculation computer then transfers the message to obile and mobile replies that message automatically to the original sender, i wanna design my application in c-sharp which can do such task. can anyone help me ot in this matter.
0
2556
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 Model to Capture More Meaning (1979) # Addison Wesley - Database Design for Mere Mortals chm # Addison Wesley - Refactoring Databases Evolutionary Database Design (2006) # Apress Beginning Databases with PostgreSQL From Novice to Professional...
0
9456
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.