How to use Microsoft Access?
Discussion Unit 8: Databases
Assignment Unit 8: Database Design Tips
One
advantage for using excel spread sheet is its really easy to use and be
productive and allows us to use many different formulas and calculations
efficiently. But as that process gets more advanced it becomes harder to get
the excel sheets to perform the way a database would. Especially when it comes
to usage for websites. There are a couple advantages that databases have:
- Data structure and
normalization through multiple tables
- Scalability: adding more
records is free
- Data and Referential Integrity
- Queries and Reports
- Automation through Macros and
VBA Modules
When it comes to the ability to
verify data and change records on the fly databases excel. When it comes to
databases most of my understanding is on the SQL side of things and for this particular
paper aside from providing examples of Excel and Microsoft Access, I figured I
would also show MySQL table.
DROP TABLE IF EXISTS `cp_loginlog`;
CREATE TABLE `cp_loginlog` (
`id` int(11) NOT
NULL AUTO_INCREMENT,
`account_id` int(10)
DEFAULT NULL,
`username`
varchar(23) NOT NULL,
`password`
varchar(32) NOT NULL,
`ip` varchar(15) NOT
NULL,
`login_date`
datetime NOT NULL,
`error_code`
tinyint(1) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `account_id`
(`account_id`)
) ENGINE=MyISAM AUTO_INCREMENT=2846
DEFAULT CHARSET=utf8;
The key difference in MS access is
its setup to handle small numbers of user’s and data requests. When I was using
MySQL, it was on enterprise servers.
This table was the login table
which showed the ID, Account ID, username, password, IP address, login date,
and error code. The engine of MyISAM doesn’t exist in MS access because it’s a
non-transactional database system meaning there’s no rollback option if a
database update doesn’t commit. And Auto incrementing means the ID of the
database will start at 2846 and count down. As follows:
INSERT INTO `cp_loginlog`
(`id`,`account_id`,`username`,`password`,`ip`,`login_date`,`error_code`) VALUES
(2845,2001045,'catlover','12345678','203.77.152.10','2022-12-20
10:04:12',NULL),
(2844,2000000,'TrueNoir','cats123','75.181.120.54','2022-12-18
15:08:38',NULL);
Here is an example of the same data
above as a excel spreadsheet. Some of our limitations are that we cannot have
automatic incrementing numbers for ID we have to manually put that data in the
server can’t access a excel spreadsheet in order to use it for login data.
Also, our input data is only as good as the person submitting. When it comes to
making mistakes it’s the person who entered the data who is responsible. In
Access or MySQL both database types aren’t at risk in the same way because
there’s limitations such as putting characters in a Integer only column and
database can be updated based on the users connecting allowing much more
dynamic system in a database over spreadsheets. Also, PHP website would be
unable to grab query information to display if we where using excel. Microsoft
Access can be used in that same way only the query language for access is very
different then attempting to write it like SQL but that’s also because
Microsoft Access is more GUI based then when it comes to MySQL if you do not
understand how to write SQL query language you will have difficulty managing
the database without extra tools such as Query Admin at the time I was working
with databases there was very limited resources when it came to software which
could be used so the only option was to learn how to write queries.
For Microsoft Access the table
would be like this:
Sub CreateTableX7()
Dim dbs As Database
' Modify this line to include the path to Loginlog
' on your computer.
Set dbs = OpenDatabase("Loginlog.mdb")
dbs.Execute "CREATE TABLE Loginlog " _
& "(ID INT, AccountID INT, " _
& "(username CHAR, password CHAR, " _
& "(IP INT, " _
& "login_date DATETIME, " _
& "error_code INT [NOT] NULL, " _
& "CONSTRAINT LoginlogConstraint UNIQUE " _
& "(ID, AccountID, username, password, IP,
login_date));"
dbs.Close
Function FixIPAddress(str As String) As String
'trim out spaces in an ip address
Dim v As Variant
Dim temp As String
Dim i As Long
v = Split(str, ".")
For i = LBound(v) To UBound(v)
temp = temp &
Trim$(v(i)) & "."
Next i
If Len(temp) > 0 Then
temp = Left$(temp,
Len(temp) - 1)
End If
FixIPAddress = temp
Private Sub Text1_AfterUpdate()
If Not IsNull(Me.Text1) Then
Me.Text1 =
FixIPAddress(Me.Text1)
If Not
IsValidIPAddress(Me.Text1) Then
MsgBox "Input
Values not Valid?"
Me.Text1.SetFocus
End If
Else
'comment this out if
we don't care about nulls
MsgBox "Do we
care that this is null?"
Me.Text1.SetFocus
End If
End Sub
Comments
Post a Comment