How to make database design for multiple information included table? - sql-server

How to design one to one database table?
I have a report that gets data from users. But report includes multiple type of records.
Report includes following information:
Customer information (name, age, city, ...)
Company information (name, address, coutry, year, ...)
Device information (devname, code, serialnumber,...)
Approve information (who_approved, date, ..)
and more information.
So I have a report table. But should create only one report table and add all columns in this table?
Or should I create a Reports table and CustomerInformation, CompanyInformation, DeviceInformation, ApproveInformation and one to one relationships?

First of all, you should know if you are going with MYSQL or MongoDB.
In MYSQL, it is not a good approach to use clustered table. While, in MongoDB, using clustered table is always an option.
Anyways, normalizing the database is the best approach. Which means, you should make more tables if possible but avoid data redundancy

Related

Oracle APEX - Data Modeling & Primary Keys

I'm creating a rather large APEX application which allows managers to go in and record statistics for associates in the company. Currently we have a database in oracle with data from AD which hold all the associates information. Name, Manager, Employee ID, etc.
Now I'm responsible for creating and modeling a table that will house all their stats for each employee. The table I have created has over 90+ columns in it. Some contain data such as:
Documents Processed
Calls Received
Amount of Doc 1 Processed
Amount of Doc 2 Processed
and the list goes on for well over 90 attributes. So here is my question:
When creating this table in my application with so many different columns how would I go about choosing a primary key that's appropriate? Should I link it to our employee table using the employees identification which is unique (each have a associate number)?
Secondly, how can I create these tables (and possibly form) to allow me to associate the statistic I am entering for an individual to the actual individual?
I have ordered two books from amazon on data modeling since I am new to APEX and DBA design. Not a fresh chicken, but new enough to need some guidance. An additional problem I am running into is that each form can have only 60 fields to it. So I had thought about creating tables for different functions out of my 90+ I have.
Thanks
4.2 allows for 200 items per page.
oracle apex component limits
A couple of questions come to mind:
Are you sure that the employee Ids are not recyclable? If these ids are unique and not recycled.. you've found yourself a good primary key.
What do you plan on doing when you decide to add a new metric? Seems like you might have to add a new column to your rather large and likely not normalized table.
I'd recommend a vertical table for your metrics.. you can use oracle's pivot function to make your data appear more like a horizontal table.
If you went this route you would store your employee Id in one column, your metric key in another, and value...
I'd recommend that you create a metric table consisting of a primary key, a metric label, an active indicator, creation timestamp, creation user id, modified timestamp, modified user id.
This metric table will allow you to add new metrics, change the name of the metric, deactivate a metric, and determine who changed what and when.
This would be a much more flexible approach in my opinion. You may also want to think about audit logs.

Where should I store repetitive data in Access?

I'm creating this little Access DB, for the HR department to store all data related to all the training sessions that the company organizes for all the employees.
So, I have a Training Session table with information like date, subject, place, observations, trainer, etc, and the unique ID number.
Then there's the Personnel table, with employer ID (which is also the unique table number), names and working department.
So, after that I need another table that keeps a record of all the attendants of each training session. And here's the question, should I use a table for that in the first place? Does it have to be one table for each training session to store the attendants?
I've used excel for quite some time now, but I'm very new to Access and databases (even small ones like this). Any information will be highly appreciated.
Thanks in advance!
It should be one table for persons, one table for trainings, and one for participation/attendance, to minimize (or best: avoid) repetition. Your tables should use primary and foreign keys, so that there are one-to-many relationships between trainings and attendances as well as people and attendances (the attendances table would then have a column referring to the person who attended, and another column referring to the training session).
Google "database normalization" for more detail and variations of that principle (https://en.wikipedia.org/wiki/Database_normalization).

Database will be used for statistics/charts/graphs. Table orginization the right way?

This database will be used to log a users substance use. So a user will be able to input the date they did a certain substance, the actual substance and the amount of the substance done in that specific session.
Currently I only have 2 tables. users, and records. The records table has the following values;
record_id, substance, date_use, amount, user_id
Many substances will obviously be repeated by the same or by different users.
Is this the most optimal way to organize my data when keeping in mind that I will and plan to use this to create statistics? Any links on database orgnization tips?
You'll want something along the lines of this:
Tables
substances
users
substances_users
You'll want to use the hasMany Through associations.
Where 'substances_users' has a user_id, substance_id, and date_used field.
That way, you have a table of substances that you can manage to keep from having duplicates, and allow you to build statistics more easily.

How can I make a form input for multiple tables in Microsoft Access 2010?

I want to make a form in Access 2010 that would allow me to enter the information about an invoice, and be able to choose the name of a customer, a store, and an employee to associate that invoice with. The customers, stores, and employees are stored in separate tables with mapping tables (i.e. invoice-customer, which just has InvoiceID and CustID) connecting them to invoice.
When I make a form that only makes records for a single table's information, I can use the form to make new records and edit previous records fine, but when I any form I make that has information from other tables, it will only display current records, not make new records or edit them. How can I make a form that works that way?
You may wish to read Fundamentals of Relational Database Design, Paul Litwin, 2003, I suspect you do not need the junction tables for customer, store and employee - junction tables are generally only needed when you can have several of something associated with one of something else, for example, several locations for one invoice.
This would make things a lot easier for you, because you could use comboboxes to allow the user to select these items by name, which would then write the id back to the invoice table.
You might like to look at the Northwind database (nwind.mdb) for some ideas. It ships with all versions of Access.

Database naming of columns with PII and sensitive information

I am working with database tables that contains PII and sensitive information. Some of the data is PII and company sensitive information. The design document may not always be available to the developer especially when the data is being exposed by a view outside of the database (Oracle database link) to another program.
Is there good naming conventions for letting the developers know the column contains PII or sensitive information?
Column names? Weak.
Use a table of PII data that contains all of the PII attributes. Keep the PII tables separate from other tables with non-PII.
A one-to-one join between the non-PII and PII isn't all that costly. And it provides clear, obvious use of the PII table and PII columns.
I agree with S.Lott but I'll be more explicit. If the data are sensitive then it's even MORE important that column names be chosen to mean what they actually contain, that datatypes be actually appropriate for the contents; and the constraints actually match the problem domain.
Then, on top of that, move this stuff to another table, where they can be appropriately encrypted, stored in the correct location, etc.
I would have separate views (eg table PERSON with PERSON_BASIC having no PII columns and PERSON_PII with the PII columns). That way, if it is later decided that a column is sensitive (eg Date of Birth), then you can easily recreate the views to remove the column from the basic view rather than some massive data restructuring exercise which you would get with separate tables.
Also, the optimizer is getting better at correlation between columns on the same table (and you'd expect that to improve over time). Once you start joining non-PII tables to PII tables, you've just made it more complicated.
If you do go for separate tables, and think they'll need to be joined often, look into clusters so that the records for the same person are on the same block.
Consider using a role secured by a password or through a package to control access to the PII view/columns.
CONTEXT can do this too. They are forced to call the package to set the context before they see the columns.
The view could be
SELECT name, date_of_birth,
case when SYS_CONTEXT('SEC','xxx') ='ALLOW' THEN ssn END
from ...

Resources