View Full Version : Sql???
DELOCH
06-24-2006, 05:33 PM
I always thought to access a database you must have a database to access...
but with SQL in ASP,PHP,PERL it never says connect to this dataase, it may have
sql_conenct($sql, "root") but not sql_setConn(database.mdb)
I do not understand this, This makes absolutely no sence to me
sorry but seriously :(
Thanks for help
Brandoe85
06-24-2006, 06:18 PM
It does...php has mysql_select_db() (http://us3.php.net/mysql_select_db)
in asp you pass it in the connection string:
http://www.w3schools.com/ado/met_conn_open.asp
Haven't done perl forever, but I know they have one as well.
oracleguy
06-24-2006, 08:20 PM
In your example you are talking about a .mdb which is an access database. It only has one database. I've never connected to one using PHP before but in ASP you don't need to select the database because the correct ODBC driver for access DBs doesn't require it.
DELOCH
06-25-2006, 05:20 AM
in other words it selects data from thin air from god's plate?
this makes no sence? you can't connect to a single database?
Brandoe85
06-25-2006, 06:12 AM
in other words it selects data from thin air from god's plate?
this makes no sence? you can't connect to a single database?
Please, did you read the links I posted?
ASP:
conn.Open "c:/webdata/northwind.mdb"
PHP:
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Not connected : ' . mysql_error());
}
// make foo the current db
$db_selected = mysql_select_db('foo', $link);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}
?>
Like oracleguy stated, a .mdb is a database. If you connect to sql server or mysql you're connecting to the database server and then selecting the database.
DELOCH
06-25-2006, 07:21 AM
ooh thanks a lot!
I believe you started about SERVER_DATABASE;
I never heard of it,
I thought a database is a simple table used to contain information, but with SQL you can manipulate that data...
but a Server database?
that does not compile in my head lol :D
oracleguy
06-27-2006, 06:57 PM
A database is not a single table. A database is made up of usually several tables and can be agmented with things like stored procedures and views.
You use SQL to interact with the data stored in a database to do whatever it is you want.
And as explained before an access database (.mdb) is a single database so when you connect to that file, there is no database selection neeeded because there is only one.
Database servers e.g. Microsoft SQL Server (aka SQL Server) or MySQL have multiple databases on one server. So when you connect to the server you need to select a database to use.
DELOCH
06-27-2006, 11:03 PM
k, I understand now, but there are still 2 things bothering me
1) I still do not know where the stuff is saved to, such as you select a string from a database(the root one) but how does it know if it is database.sql, or etc
2) I use http://localhost/phpmyadmin to create a database, but it creates an odd thing like: values, types, index, and etc but it does not create a table by using rows and cols like Microsoft Access could :\
oracleguy
06-30-2006, 05:12 PM
1) The data is saved in the different places depending on the database server. Usually it is some place below where the server software was installed.
2) phpMyAdmin is just a tool for interacting with mySQL. Anyways though, you create a table and you give create columns and select the data type, the size, optionally any default values, indexes or constraints you'd like to place on the column. Then once you have the table you can insert rows.
If you are refering to the way you can insert data in access by looking at the all the data in a grid and typing new stuff in, phpMyAdmin doesn't work like that. You could make mySQL do that, you'd either have to write a program to do it or find one that already does. But in the end it doesn't matter, phpMyAdmin works exceptionally well with working phpMyAdmin but it isn't the only tool out there for doing so.
TheShaner
06-30-2006, 05:57 PM
Deloch, the problem is that you're attempting to compare an access database with all the other databases, when Access is a "dumbed-down" version of a real database (and when you open an Access database you've saved, you're opening ONE database, just like in MySQL when you SELECT a database). Access is unlike all the rest in many ways. I work with Access on a daily basis it's actually the main reason my company hired me on, haha). Access really simplifies (or dumbs down) the database approach so that people without database experience can actually utilize it. MS SQL, MySQL, PostGreSQL, Oracle, etc. are not as "user friendly" as Access is.
Now, I know you're getting confused with Index, Data Type, Length, etc. But these are all present in Access. You just don't realize it. When you select Text, Number, Memo, etc. in Access, you're selecting a Data Type.
For example:
Access:
Data Type -> Number
Field Size -> Long Integer
MySQL:
Data Type -> BIGINT
Length -> (whatever you want, or can be left blank to be defaulted)
Access:
Data Type -> Text
Field Size -> 100
MySQL:
Data Type -> TINYTEXT
Length -> 100
As you can see, they are similar in some ways and share the same features. MySQL just gives you more options to be completely specific on the size of the content that will be displayed in that field.
As for Primary Key and Index in MySQL; you have that in Access too. You set a primary key by clicking the Key icon. In the General tab for a field in Access, you select Yes or No for the Indexed option. In MySQL, you select one of the radio buttons for primary key or index (if you're using phpMyAdmin).
I just think you've never really messed around with the options that are there for Access and allowed defaults to just be used, so you're unaware of what's really going on with the Access database. Plus the fact that MySQL is much more specific and geared toward database programmers.
Another hurdle you're having trouble with is that Access has a GUI (graphical user interface), whereas your others don't really have one as much. There are programs, like phpMyAdmin, that attempt to add a UI to these databases so that they're more friendly and help people who are less experienced in the database world. phpMyAdmin has rows and columns of a sort. When you're viewing your database, select a table, and then select the Structure tab. You'll see all your fields you've defined (if any) just as if you were in Design mode of a table in Access. If you click the Browse tab in phpMyAdmin, all your input will be shown in rows with their respective field names above just as if you were in Datasheet view in Access. Now, it's not as easily accessible as Access. You can't just click in the field and start typing. But you select a row by clicking the checkbox, click edit, and then you can edit that row. You don't have the easy UI as you do in Access, but it's all there (and more).
I think you would understand more if you learned more about how databases work. Then you'll realize that Access is doing most of the same things the other databases do, except just behind the scenes so that the user doesn't have to worry about them. Of course, this leads to much less control over your database, which is one of the areas Access fails (among many others).
-Shane
Beagle
06-30-2006, 08:56 PM
Ok, first I'll give a quick and dirty version, then you should read the wikipedia articles on databases:
A database is a VERY simple concept; it is a collection of data stored externally to an application (on a filesystem) for read/write access by an application. Text files can be databases, in fact, in FoxPro for DOS, as well as many MUD (multi-user dungeon) engines, that's exactly what their databases are, a collection of flat files. It's just data, stored somewhere.
A database is NOT inherently relational, NOT inherently stored in b-trees, NOT inherently accessible by SQL (structured query language).
That's why people created relational databases. There are also object-oriented databases. There are other types of databases.
Then there are Database Management Systems (DBMS)
Access databases are basically data stored in a single-file (mdb). It can contain multiple tables per database. The file itself doesn't know anything about SQL, it's the driver you use to access it that does.
Access is a simple DBMS because it allows you to manipulate multiple databases.
MySql, Postgresql, Oracle, and MSSQL are quite complex DBMSs. They are server applications that run waiting for connections, then serve up data to whatever client accesses them. They all happen to implement SQL as their query language. They could have easily decided to use a completely different query language. In fact, Oracle still uses some non-standard syntax from their own query language they developed a long time ago.
When you access an Access database file, you have to do so through something like an ADO or ODBC connection, because it's a driver that knows how to read the file and interact with it in a user-friendly way. You could write your own by reading the file and implementing the seek, append, and truncate commands required to add, remove, and retrieve data.
MySQL MyISAM tables are stored as separate files. Each table gets its own file. MySQL InnoDB tables and Postgresql tables are all stored mashed together. But you never interact with the files anyway. There's a server application in between you and the data that processes your queries, executes them, and gives you back the data the way you expect it.
I recommend checking out wikipedia now. I went way over my self-imposed limit.:p
DELOCH
07-02-2006, 08:02 AM
ok thanks :D
I think I'm starting to get it...
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.