database

little mysql help here please

I have a classified webs. Users may put classifieds in, and each category has sub options. Ex: User picks CAR, and has to fill in options such as color, mileage, fuel, gearbox etc. Here are my tables for this: Category table: cat_id (PK) cat_name // "Cars" for example Category Options table: option_id (PK) cat_id (FK) option_name //...

Securing php application

Hi , I have built a cms from scratch in PHP and I need a little help with getting it more secure. Basically I have arranged all my important files as followed: /var/www/TESTUSERNAME/includes/val.php Is this a secure way to stop people from getting hold of my values ? Would it be a better to store these values in a database then ru...

Implementing custom fields with ALTER TABLE

We are currently thinking about different ways to implement custom fields for our web application. Users should be able to define custom fields for certain entities and fill in/view this data (and possibly query the data later on). I understand that there are different ways to implement custom fields (e.g. using a name/value table or us...

Fine-tuning my MySQL relations database and how to use JOIN on it?

I am very new to mysql and databases, so I need help here... How should I use JOIN to fetch a record from the tables below, when the only given variable is the ad_id? category and category options are filled in manually i.e. the users may not alter them. So they are only reference tables, but I am not sure this is how I should do it......

How to specify the name of a database to get the name of its tables using sql server 2005 syntax

I need to write a querry in SQL SERVER 2005 to get the name of the tables of a specified database name. So i need the syntax to specify the name of the database using SQL SERVER 2005. Does anyone have any idea ? Thanks in advance for your help. ...

Storing messages as BLOB (Binary Large Object) or ordinary text?

What is the best way to store messaging texts in large/big web sites: BLOB or ordinary text in table or something else? Database: MySQL. ...

Filtering duplicities by another table.

Hello, I have two (example) tables here A) data_table: +----------+-------+ | location | value | +----------+-------+ | 43 | 38 | | 44 | 31 | | 3 | 31 | | 11 | 38 | | 47 | 35 | | 49 | 31 | | 50 | 31 | | 55 | 16 | | 56 | 16 | | 59 | 35 | ...

SQL Server - Limit the databases view based on login

Hi there, I have a situation where I want to limit the database view per user login. For example: I have 3 databases in my SQL Server instance called MyDB, UserDB, RestrictedDB. I then create a 2 logins; User1 and User2. I then did a DENY VIEW ANY DATABASE TO [User1] and then DENY VIEW ANY DATABASE TO [User2]. I then made User1 the ow...

Is it a good idea to duplicate columns across tables in order to enforce check constraints?

I'm faced with a situation where I have two tables: A and B. B has a foreign key to A. A has a column "Detailed" which identifies whether or not its children in B require their "Details" section to be filled out. If I have my lean structure there is no way for me to determine if a record in B needs to have its "Details" section filled...

Connect multiple JCR repositories to one database (and keep updated)

I am a little bit stuck in the moment because I don't know if my problem is solvable at all. I have one database (MySQL) where a JCR repo is stored. Secondly do I have two webapps (edit/live) that share this data. Live is designed to read only, so it can (really??) be considered save regarding concurrency. My problem is that everythin...

Split Address column into separate columns in SQL view

I have an Address column in a table that I need to split into multiple columns in a view in SQL Server 2005. I need to split the column on the line feed character, chr(10), and there could be from 1 to 4 lines (0 to 3 line feeds) in the column. Below are a couple of examples of what I need to do. What is the simplest way to make this h...

Character set in MySQL; Can't insert special characters, why?

I can't insert special characters. Whenever I try to, all characters BEFORE the special character gets inserted, but after the special character nothing is inserted into the field. $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); mysql_select_db($dbname,$conn); mysql_set_charset('utf-8', $conn); mys...

Edited- MySQL. Large MyISAM table (40mln records) having index that is very slow and huge in size on disk

The table contains about 40,000,000 records having: CREATE TABLE `event` ( `id` bigint(20) unsigned NOT NULL auto_increment, `some_other_id_not_fk` int(10) unsigned default NOT NULL, `event_time` datetime NOT NULL, `radius` float default NULL, `how_heavy` smallint(6) default NULL, PRIMARY KEY (`id`), KEY `event_some_other...

How to keep testing and production e-commerce db in sync when you have "sales" updates in production?

I've read the following thread in SO, Keeping testing and production server environments clean, in sync, and consistent, and I still have some doubts in what is the best way to do it. "You should do modifications to your test environment and replicate it to your production server". Problem is I'm using Magento installation: I have diffe...

Another mysql JOIN question...

I have these tables: classified: classified_id (PK) price headline cat_id // THIS IS ANYTHING FROM 1 TO 30 DEPENDING ON CATEGORY. IT IS SO THAT I CAN LINK WHICH CATEGORY TO USE IN THE CATEGORY TABLE BELOW text etc... category: cat_id (PK) cat_name category_options: option_id (PK) cat_id (FK) // FOREIGN KEY FROM CATEGORY TABLE... optio...

Matching a field with variable number of leading zeroes in SQL Server table

I have a situation where I have an incoming data value that may or may not have leading zeroes. I need to match that to a field/row in a SQL Server table. The field value in the SQL Server database may or may not have leading zeroes as well. So, I might have: incoming = 5042800138 and the value in db can be any of 5042800138, 05042800...

MySQL headache, should I or should I not?

I have a classifieds website. I am using SOLR for indexing and storing data. Then I also have a MySQL db with some more information about the classified which I dont store or index. Now, I have a pretty normalized db with 4 tables. Whenever ads are searched on the website, SOLR does the searching and returns an array of ID_numbers whic...

SQL function to sort by most popular content

I don't know if this is possible with SQL: I have two tables, one of content, each with an integer ID, and a table of comments each with an "On" field denoting the content it is on. I'd like to receive the content in order of how many comments have it in their "On" field, and was hoping SQL could do it. ...

How to store Markdown comments

I want to use Markdown for my website's commenting system but I have stumbled upon the following problem: What should I store in the database - the original comment in Markdown, the parsed comment in HTML, or both? I need the HTML version for viewing and the Markdown version if the user needs to edit his comment. If I store the Markdown...

How to update a database remotely?

Hi, all. I'm looking for a strategy to allow automatic updates for a number of databases at customer sites through a publish-subscribe kind of mechanism. Right now there is a datacenter which has all the master data that get fed through extractions from hundreds of databases out there. The problem is that, whenever I need to do create a...