Design Datatabase tables structure - database

I am new in this and try to found information in the web have not got any success. I need to create some log tables but have no idea what information should this table contains and how to organize them.
For example:
LogErrorTabble, LogChangesTable, etc..
Could anyone give me some articles about this or link to site with example solutions that he has used?

First of all what log library do you use? If you're on java got for log4j, if you're on .NET go for log4net. Both of these frameworks provide db log appenders that log to the database out of the box.
In case you're not using a log library: use a log library :)
In case you really want to do that on your own I can recommend a layout I used in a project where log messages were stored in a table logs and exceptions associated with an entry in the logs table were stored in an exceptions table but that highly depends on your platform.
You can find a lot of useful information on how to design your log tables in the log4net and log4j documentation. For example take a look at the log4net AdoNetAppender Class.

Related

How to automatically save received pdf files from gmail into a database?

I would like to know if this scenario would be possible in any programming language combined with any database technology.
I would like to automatically save received pdf files that are attached in emails into a database. Is this possible? Is there any library or framework available to do so?
Yes, I would recommend using Google Apps Script for this. The approach you should follow is to use the GmailApp class (Documentation here) to get the messages you need, you can use methods like getInboxThreads() (Documentation), to retrieve the messages.
After you've found the message and retrieved the attachment (which you can do withgetAttachments() (Documentation)), you can use the JDBC Service to connect with external databases. The specifics here depend a lot on what database you want to connect with, but the documentation will lead you in the right direction.

Initialise SQLite Database in Yesod Scaffolding Site

I created a yesod project with yesod init dans chose SQLite database.
My question : How do we initialise the SQLite Database with initial entries in the Yesod Scaffoled Site at the launch? Where do we put our insert instructions in this Yesod Templace Site?
I'm talking about actually adding records to some existing tables.
The Persistence chapter in the Yesod book explains how to insert a line in the database in the Handler of a ressource, but it doesn't explain how to add database entries at the start of the Yesod site (when the Yesod site is launched using yesod devel for example).
This is probably not an efficient way to proceed, so any suggestions on the completion of this task would be helpful.
Thank you.
I've never done this before since in my usual use case the DB is used for persistence across runs.
However I think the most appropriate place to do this would be in the makeFoundation function inside the Application module
Thats where your DB resources (connection pool etc...) are initialised.
Theres a line that looks something like this:
-- Perform database migration using our application's logging settings.
runLoggingT
(Database.Persist.runPool dbconf (runMigration migrateAll) p)
(messageLoggerSource foundation logger)
That sets up your tables, its probably just after this that you want to add your records.
I think the link in your question needs to be corrected, but the Persistent chapter of the Yesod book that you referred to does have valid examples for inserting records in an IO () action, so it should be able to get you the rest of the way.
Hope this helped

What can I do with generated error logs?

I'm currently working on a web application which generates daily error (and non error) logs.
The current system outputs a log per task to a text file, and outputs critical errors as well as "start" and "finish" type messages to an email account.
The current workflow is as follows: scour the email box for errors, then go and find the .txt file to look at the associated errors and find the cause.
There are around 30 txt files split across about 5 servers.
This system was set up before me, but I'm looking for any advice on how to deal with the situation.
I have control of the script forming the error logs so can do pretty much anything - but I'm lost where to start: I'd considered some kind of web facing dashboard tool, maybe output the files to RSS or something?
Are there any external or internal tools I should be using?
Of course you may use the SQL Server Reporting Services or review this comparison table, there are some packages which may support SQL Server but they may be overwhelming for your task.
It's not really clear what your problem is or what you want to do, but if I understand correctly, your biggest problem is that some messages are logged to a log file but others are sent by email. Therefore, there is no single location that has all error messages in it and that makes analysis and troubleshooting difficult.
The best solution would be to use a logging framework that supports multiple logging destinations (file, DB, email) and severities. That would allow you to specify a configuration like "all errors are logged to a text file and critical ones are also sent by email", so you can ensure that you have everything in one place for general analysis but critical errors are also handled with priority.
You didn't mention what programming language you use, but assuming it's .NET-based then log4net and Enterprise Library are two common frameworks and there are many questions about them here on SO. Googling should give you a good idea of the pros and cons for your situation. If you're using a different language then you can look for the equivalent package: log4j (Java), logging (Python) etc.

How to make a copy of schema in Amazon RDS (Oracle)?

For all the developers in a team, i am trying to automate creating a dedicated schema for each one of them from a 'master' schema. How can I achieve this?
At the end all I want is: given 'developer_1' schema name, 'developer_1' will have all the tables, views, sequences from schema 'master' along with the index and constrains. Online search pointed to DataPump. AWS documentation seemed pretty light. I am looking to have this setup such a way that, this can be invoked every week to get latest snapshot from master schema. (blowing up whatever existed for developer_1)
Thanks,
You will likely want to you Oracle's Data Pump utility. With this, you can create a schema dump (export) and then import that dump. On import, you can use the handy REMAP_SCHEMA command-line parameter to change the schema name on import.
The links below should help get you started.
Export: http://docs.oracle.com/cd/B28359_01/server.111/b28319/dp_export.htm
Import: http://docs.oracle.com/cd/B28359_01/server.111/b28319/dp_import.htm
I was looking for something similar and found this (and then you during the google-trawling):
http://learnwithme11g.wordpress.com/2012/06/07/copy-schema-into-same-database-with-impdp/
I think you can get around the CLI access by using something like:
!mkdir /path/to/dir
then invoking:
create directory as TEMP_DIR='/path/to/dir'
in SQL*Plus.
Also, be aware that the syntax is wrong in site above.

Sharing necessary application data between developers in CakePHP

CakePHP has a process (schema shell and files) for sharing database structure between developers. However, there is often need to share some data (e.g. default user groups) as well. How have you solved this?
You can use fixtures for this. fixtures are small sets of data that can be used for testing or developing purposes. There is an interesting article about this here:
http://nuts-and-bolts-of-cakephp.com/tag/cake-fixtures/
There are also plugins which help with the whole db migration process though I didn't try them out yet you might find them interesting:
http://cakedc.com/pierre_martin/2010/02/05/cakephp-migrations-plugin-easily-version-and-deploy-whole-applications

Resources