mysql

What's the best way to design an Entity / Relationship Model?

For example if I have 20 tables, I have to design it by section? i.e CLIENT (id, name...) -- orders -- ODERS_DETAIL(id, products...) . . . lives --- ADDRESS(...) Or I can use The MySQL Workbench EER Model (To me, it looks like the Pysical Model)? Or like this: Data Modeling Levels ...

Basic table design Q

I am trying to understand this concept. For example: I have two tables City and Country. Country ------- id abbreviation name City ----- id name Country (name or id, or both? - This is the question) To reference and keep a particular city in sync with the country it belongs to I guess this will be reference to country....

Need help on MySQL DISTINCT+COUNT query

I have a table called "r", inside that table I store id, ip, and country. I am running this query: SELECT r.country, count(rr.ip), count(DISTINCT rr.ip) FROM `r` LEFT JOIN r rr ON r.country = rr.country GROUP BY r.country I do get rows with columns: "country";"number";"number"; But both "counts()" doesn not show what I want it to...

Incremental syncronization for occasionally connected clients using JDO

Hello, Is it possible to do Incremental syncronization for occasionally connected clients using JDO. I stumbled upon JDOReplicationManager but not sure whether is solves the following needs, Replication to be initiated from an web application. Replication should be a two way process. i.e. Synchronization If there is a failure in netwo...

null values after csv import

Consider a table to store SSN and DOB. CREATE TABLE fbi ( ssn BIGINT, dob DATE ) Data was loaded into the table: LOAD DATA LOCAL INFILE C:\test.csv INTO TABLE fbi FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n'; SELECT * FROM fbi; It is showing null values for DOB. I don't understand the ...

Granting the create view privilege in mysql using cpanel/myphpadmin

I am using cpanel and I wanted to grant a user create view privileges. When I created the user and database in cpanel it did not have an option for that. So I tried to do it in phpmyadmin using GRANT CREATE VIEW ON (dbname).* TO '(db username)'@'localhost'; and I get the error #1044 - Access denied for user '(host username)'@'loca...

How to strip carriage returns from text fields returned from mysql in PHP?

I am using PHP to read a text field (DESCRIPTION) from MYSQL and prepare a JSON object. Modelled on JQUERY DataTables Plug-In example. The DESCRIPTION field contains carriage returns and I believe this leads to invalid JSON. JSONLINT.com produces "Syntax error, unexpected TINVALID at line 35. Parsing failed". http://ageara.com/exp3/se...

mysql prevent deleting records that is in used

hi, i got 2 tables. product and order_items which contain all the products that were bought. so how do i create a relationship in mysql whereby if a product exists in order_items, restrict users from deleting it from product table?? thanks ...

mysql foreign key concept

CREATE TABLE parent (id INT NOT NULL, PRIMARY KEY (id) ) ENGINE=INNODB; CREATE TABLE child (id INT, parent_id INT, INDEX par_ind (parent_id), FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE CASCADE ) ENGINE=INNODB; I dont understand the meaning...

Mysql command for running .txt file

I have a .txt file in which i have created database and tables. I want to run it on mysql command line window. I used the command source C:\Dbbut it failed to open it. Do i need to use some other command for it? ...

PHP / MySQL Frameworks for a basic CRM System

Perhaps, using the word CRM is a bit of a misnomer, essentially, I'm looking for a fast and easy way to create a front-end so that others in my organization can utilize a MySQL database that I've created that manages lists of respondents to marketing research surveys. I would need to do the following through the proposed front-end: ...

delete database from mysql

what is the best way to delete database from windows mysql?I tried DELETE DATABASE phone but it doesn't work. ...

Mysql intersect results

I'm trying to do something like the PHP array_intersect. I have the following table CREATE TABLE `recipes_ingredients_items` ( `id` INTEGER(11) DEFAULT NULL, `itemid` INTEGER(11) DEFAULT NULL, `orderby` TINYINT(4) NOT NULL, KEY `id` (`id`), KEY `itemid` (`itemid`) )ENGINE=MyISAM AVG_ROW_LENGTH=47 CHARACTER SET 'utf8' COLLATE '...

PHP error: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given.

I get the following error below. Line 53 is if(mysqli_num_rows($r) == 1) {. How can I fix this problem. PHP error: on line 53: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given Here is the PHP MySQL code. $d = "UPDATE users SET del = 1, del_date = NOW() WHERE userid = '" . $_SESSION['userid'] . "'"; $r = mysqli...

Where find a free GPS coordinates database?

Hi to all for my app need to have a list of mayor woldwide cities with relative GPS coordinates for proximity search, anyone know how is possible to find a db of this type? (not API) ...

reflecting record deletions / additions between two datasets

Hi, I currently have a table of 3m records that needs updating nightly. The data that populates this table comes from ~100 APIs that all get normalised into one jumbo table. Problem: How to reflect new records being added, and records being deleted at the source? Facts: I can't truncate the table every night and reinsert. Each API pro...

table schema design problem while using innodb

I have encountered a problem when designing the table schema for our system. Here is the situation: our system has a lot of items ( more than 20 millions ), each item has an unique id, but for each item there can be lots of records. For example for the item with id 1 there are about 5000 records and each record has more than 20 attrib...

MYSQL: how can i select dates from this current day up to the next 2 months

i have to select from my homework dates from this time up to the next 2 months... i'm doing an expiration database.. pls help me ...

MySQL get only rows with a unique value for a certain field

Hi, I want to get only the rows with a unique value for a certain field (2 actually). My table is like this: id senderID receiverID ... ... ... _________________________________________________ 0 0 1 ... ... ... 1 2 1 ... ... ... 2 1 0 ...

php, mysql how can I produce a dynamic html with fields in the first column and data in the next colums ?

I found this great example which takes an sql statement and dynamically adds the field names into a header row and the data into the following rows? Heres the example http://www.weberdev.com/get_example-4249.html ...