r/DatabaseHelp • • Nov 22 '17

Proper way of handling with enabled/disabled rows in a table (eg Accounts)

2 Upvotes

What is the proper way of handling enabled/disabled rows.

For example, I have an account table and I want accounts to be disabled until they are verified.

Once a user registers it is disabled. Once the email is verified then it becomes enabled.

What is the proper way to handle this? A boolean column "enabled" and then an account view with only the enabled ones?


r/DatabaseHelp • • Nov 22 '17

How do I use a cursor to update all rows in a table vs just updating one row?

1 Upvotes

So I originally wrote the below to update just one row in my table but now I want to update the "stars" column of all rows in the same way. How do I use a cursor to do this? Thanks! DECLARE v_empno emp.employee_id%TYPE := 176; v_asterisk emp.stars%TYPE := ' '; v_sal emp.salary%TYPE; BEGIN SELECT trunc(salary / 1000) INTO v_sal FROM emp WHERE employee_id = v_empno;

FOR i IN 1..v_sal LOOP
    v_asterisk := v_asterisk
    || '*';
END LOOP;

UPDATE emp
    SET
        emp.stars = v_asterisk
WHERE
    employee_id = v_empno;

COMMIT;

END;


r/DatabaseHelp • • Nov 22 '17

I'm completely new to DBs and need some guidance.

1 Upvotes

I own a small business dealing in promotional products, like ink pens tshirts and the like.

I'm trying to come up with a solution for expanding the business to support new employees - rather than me just doing all the complicated stuff.

Currently I've been doing most everything by hand, which is error prone, and involves some complicated calculations for every single order.

I was working on an excel file which would handle the calculation of shirts sort of, and kept running into issues that couldn't easily be solved in excel.

Essentially what I'm looking for would probably be pretty similar to most small businesses in most respects. Just a secure way to enter form data for a customer database, a catalog, and then a quote generation tool.

The only part that gets custom or complex any more than just having custom entry fields that I would want, is the calculations for the shirts. There's a ton of data that has to be entered for each order, probably between 15 and 20 fields, and all of that has to come out to a price that makes sense.

I don't have a ton of money (Like I said, trying to expand the business) so I'm trying to figure out a way to do it myself. I have some background with code, and a degree in digital arts/design which did include php/mysql classes in a minor way. I.e. I took a course on it, enough to get feet wet, and that was 9 years ago.

So while I'm totally lost, I do have a basis from which to work, and I need guidance on the best/most cost effective way to start building this database and implementing interaction with it.

It's between this and trying to do it in Access. Thoughts, DatabBaseHelp?


r/DatabaseHelp • • Nov 21 '17

Full Text Search - TSVector storage

1 Upvotes

I've dabbled in some Full Text Search capabilities of PostgreSQL in a college course, and, while I get the motivation behind it - it's indubitably extremely useful - I simply cannot find the plain answer to my doubt about how it's supposed to be used.

The thing is, I envisioned using FTS like this, from the perspective of the DB: the table containing the text metadata (title, author, publication date, stuff like that) should also contain a TSvector field. The table should also have a trigger set up so that when a body of text is inserted into a database, the TSvector is automatically generated and stored into the database for faster lookup later on.

Then, when a query comes along, it's converted into a TSquery and then a FTS lookup is done in order to find a matching TSvector, or get the ranking of results or whatever.

However, I've never ever seen this put so succinctly, nor have I seen any single working example that uses FTS in such a manner. All the docs, guides, tutorials simply point out the lookup by generating a couple of short TSvector on-the-fly and querying against them. I cannot find a reference to a TSvector field being used in the design of a schema.

So, am I missing something, or is this so very straightforward that nobody bothered to even speak of it?


r/DatabaseHelp • • Nov 19 '17

Database Recovery Question

1 Upvotes

Hello,

I am supposed to write a term paper on database backup and recovery, but I am struggling with finding good sources. Most sources focus on concrete DBMS like Oracle for example. I need to look at the topic from a broad angle. I am interested if you know any good sources on database recovery, that isnt talking about Oracle/Mysql/... specific stuff. For example I wrote a bit about point in time recovery, but its not enough. Basically I need something that can be applied to every/most relational databases.

Thank you!


r/DatabaseHelp • • Nov 15 '17

Relationships java help

1 Upvotes

I'm making a UML diagram and trying to define the relationship between things.

Can you explain the difference between the following:

One-To-Many Relationship, One-To-One Relationship, Zero-To-One Relationship, Zero-To-Many Relationship

Basically, I'm making relationships between the following things: University, School, Department

I made a composition relationship from: University > School > Department

and I just assigned a one-to-many relationship for all of them because I'm not sure which I would apply?

Please help if you can!! Thanks.


r/DatabaseHelp • • Nov 15 '17

Need some help with cassandra installation?

1 Upvotes

Hey everyone, I am university student who recently joined a drilling (oil and gas) research lab. One of the initial tasks they wanted me to do is play around with Cassandra and figure out some basic stuff, namely how to pull in/out data, and how to do that with python, and also investigate how it might compare to other types of databases.

A week ago, I literally did not even know what a database was, much less any of the more complicated topics, etc. However, I do know how to code in python.

I feel like this should be easier, but in order to do any of what I said above, I would need to install Cassandra on my windows 10 laptop, which is where I am stuck.

Can anyone provide simple step by step instructions that won't fly over my head on how to install it and just get something running?

So many of the resources I've seen so far I get stuck on or don't lead anywhere. For example, I went to download cassandra from apache.cassandra.org and there was some bin.tar.gz file which I didn't know what to do with. A book I found seemed promising and it had me start using the command line (which I'm also not familiar with) but halfway through installation steps I discovered that it wasn't even for windows which explains why my commands weren't working.

I just can't figure out this issue which I think should really be something trivial. Just used to hitting download and then double clicking to install.


r/DatabaseHelp • • Nov 15 '17

Help normalising this simple abstract relationship into BCNF?

1 Upvotes

I have a really simple abstract database schema and set of functional dependencies: https://imgur.com/a/wP7ZU

And I am asked to normalise it. I have the answer but I am unsure how they arrived at it.

I know that the candidate keys are A, BC and CD


r/DatabaseHelp • • Nov 13 '17

What are the best resources to learn about master data management and how a big organization would implement it? (e.g. on the scale of companies like Target / Walmart, CVS, or Bank of America)?

2 Upvotes

r/DatabaseHelp • • Nov 12 '17

Is there an RDB that supports optional parameters for sprocs and something like MySQL's "IGNORE" for CRUD operations?

1 Upvotes

Long story short, I went with MySql over MSSQL in part because I could attempt inserts where sometimes the primary key already exists and it's simply ignored and the rest of the INSERT operation is executed. Good stuff. What's not good stuff is MySql still does not support optional parameters for stored procedures.

Is there a relational database that supports both of these things? I have looked at the big ones like Postgres and MariaDB, but I was hoping someone out there could quickly and easily chime in with a suggestion that they already know supports both of these features.


r/DatabaseHelp • • Nov 07 '17

Inheritance and "matching" table issue in converting class diagram to relational model.

1 Upvotes

For a school project, I'm supposed to design the systems of a previous semester's project. We're using UML, creating an extremely simple use case diagram (no <<extend>> type nonsense, just actors pointing at use cases inside of a system), from which we make a class diagram, then a relational model.

Use Case and Class Diagram: https://imgur.com/a/yDvbm

My application lets people/restaurants list food they're willing to donate. Charities that feed the homeless request food. If there's a match, the donor is able to appear on a Map overlay a la Uber, where Charities can pick a route to fit their needs.

I'm having trouble figuring out how to represent matching, as well as if this diamond of the FoodItems and matching connecting to route makes any sense. I know inheritance is generally a bad idea in relational modeling. Is it just a matter of having FKs everywhere? I feel like I'm walking in circles.

edit: also realizing I probably need the Maps API in there somewhere...


r/DatabaseHelp • • Nov 04 '17

Looking for the easiest way to build a front end and secure db.

1 Upvotes

I am trying to put together a simple database to hold a bunch of member's names, phone numbers and home addresses. I need it to be secure (due to personal information), and have some sort of web front end. Additionally, the DB needs to be easy for non tech savvy people to maintain and use in the future. I have a basic understanding of SQL, Angularfire (Angular+ and firebase), and a strong grasp of web frontend. My supervisor suggested looking at Access and/or Excel Databases as a possible solution. Does anyone have any suggestions?


r/DatabaseHelp • • Nov 03 '17

Is there a good cloud-based SQL server option I can use with MS Access?

1 Upvotes

Looking to do some light-use databasing and want to be able to use MS Access and connect to the data from anywhere. Any suggestions on how to do this?


r/DatabaseHelp • • Nov 02 '17

Help translating an ER "is a" into SQL

1 Upvotes

Hi, so I have an assignment where I have a few relations:

Student( ID, name, major).

UGrad( UGYEAR ).

PGrad( specialization_track ).

I have ommitted the data types for clarity. The problem states: "A student is either a ugrad or a pgrad" with all the attributes within Student and the respective attribute from either ugrad/pgrad.

Within SQL, how do I define these tables and relate them so that it is impossible to create a tuple within Student without going through either ugrad/pgrad while still inheriting the attributes of Student? I cannot have two tables with redundant columns for StudentID, name and major.


r/DatabaseHelp • • Nov 01 '17

Best Platform for Project Tracking and Client Management?

1 Upvotes

Hi there,

I'm taking over a small consulting practice that has operated with what seems to me to be a clunky and outdated database system. Our admin person is averse to change and has kept a FileMaker 8 Pro system running for more than a decade. I want the ability to migrate existing data files (~2,000 records) into a new system, change the data entry interface, and have it searchable remotely by all consultants (currently, files can only be accessed by our admin physically on site). I've looked into simply upgrading FM Pro but am wondering if there is anything better suited to our simple requirements. I am unfamiliar with FM programming so would have to learn.

Current setup is simple and includes basic elements like project name and description, client contact info, milestones, invoice dates and amounts, etc. It's barely searchable and has a clunky input interface. Project files (i.e. reports, invoices, communications) are in no way linked to the database. What I want is something sleek, could include more advanced keyword search, is accessible online (or at least remotely), and can store (or link to) all related project files.

Any suggestions?

Thanks, Chris


r/DatabaseHelp • • Oct 31 '17

Should I inherit a foreign key?

1 Upvotes

Should I inherit the prod_type_id key into the "sold" table as shown in the image below? https://i.imgur.com/HwtALoH.jpg


r/DatabaseHelp • • Oct 30 '17

I need help understanding Database normalization and, specifically, 1NF

2 Upvotes

Hey guys! I am a beginner in Databases (I study Informatics and I am in my third year) and I would appreciate some help in understanding the concept of Database normalization and, specificaly, 1NF. Thanks in advance!


r/DatabaseHelp • • Oct 26 '17

Schema for attendance tracking app - accomodating students with no existing records (yet)

1 Upvotes

I'm making an app to track student attendance. I know that sounds like a homework assignment, but it's a personal project. I have tried a variety of schema, but I keep running into issues in business logic. This is my current schema in Django after much simplification.

 Tables:
      Course (uuid, user, name, location, etc., no FKs)
      Student (uuid, name and level, no FKs)
      Record (uuid, week, day, status, no FKs)

 Joining Tables:
      CourseRecord (Course FK, Student FK, Record FK)
      ??? (Perhaps add a CourseStudent with Course FK and Student FK?)

Any advice would be appreciated. Some further info if it helps:

Business logic: I have a page that lists all courses where the user can click a button to redirect. Upon clicking, it goes to a page for retrieving records where Course's user is the same as the user themself and Course's uuid matches a provided one. The records are then converted via a hacky spaghetti homebrew algorithm to student objects. Finally, the student objects are displayed.

My issue: I'm unable to display students without records because having a CourseRecord row with an empty record FK field seems like bad design. Thus, course and students are not connected because CourseRecord has no rows.

Thank you.


r/DatabaseHelp • • Oct 25 '17

Database for leasing systems with multiple components

1 Upvotes

I work at a company that leases about 12 systems worldwide that we need to do a better job of tracking. Each system has something like 20 components in it and the components can often be moved to a different system. These systems get sent around the world and we need to keep track of where every system is, where every component is, and a history of where each system and each component has been.

I have no experience with databases, but have pretty good experience working in excel (if that counts for anything). How would you go about making this database? What software would you use? Would this be something I'd be able to teach myself or something that we should contract out? Any thoughts or suggestions are much appreciated.


r/DatabaseHelp • • Oct 23 '17

Identifying relationship or not?

1 Upvotes

Assuming I have Users with Accounts (1:n). My account table must obviously store the user_id. However, just as a Foreign key or also as a Primary Key?

So with Accounts(id, user_id, ...) shall I have upon Account creation

Accounts(5001, 3, ...) [PK, FK]
Accounts(5002, 9, ...) [PK, FK]

or

Accounts(2, 3, ...) [PK, PK&FK]
Accounts(2, 9, ...) [PK, PK&FK]

Are there any guidelines on how to decide this? The second one would have the disadvantage that I'll have to use two columns in every other table I have to reference the account. But on the other hand, my account_ids do not "grow" that fast.


r/DatabaseHelp • • Oct 18 '17

Help in automatically updating and maintaining a database of contact info.

1 Upvotes

Greetings r/DatabaseHelp!

I have been put in charge of finding a program or some method to make updating and maintaining our database of potential participants easier. Basically, we have various consumer studies and we need to have a database of people that we can contact to see if they are interested in participating. We also need to be able to sort through the people so we can only contact the people who might qualify.

Right now, we are using a combination of SurveyMonkey and Microsoft Excel. This involves downloading the SurveyMonkey data from our various studies, manipulating them to fit with the formatting, and then pasting them into the excel file that I'm currently using. It would also be nice if there was some way to automatically update ages so we can see how old they are currently

Are there any programs that would make this process easier? Specifically, anything that might be able to automatically input the data into the database?

I'm a little lost in how to make this process go smoother, so any help would be greatly appreciated!


r/DatabaseHelp • • Oct 18 '17

Oracle Database Help :(

1 Upvotes

Hey /r/databasehelp,

I'm new to oracle (D-OH!). Setting up an Oracle listener i'm noticing 2 things:

  • The listener status is showing Unknown.
  • When I try to log into SQL, I'm receiving the error: 'TNS:could not resolve the connect identifier specified'.

r/DatabaseHelp • • Oct 16 '17

Microsoft Visual FoxPro Syntax Help please!

1 Upvotes

So I have this problem. Opened my database table in foxpro. I'm using VFP 8.0 for reference sake. It's a customer data table for a store. I tried to import the table into Excel but Excel clips the info so I am trying to filter the table down so only pertinent info stays (people who spent more than $20 on a single ticket in the last 2 years)

My problem is that I am in no way shape or form a developer, a programmer, or anything of the sort so I am relying on google for my syntax.

My question: I have multiple fields in this table. I have taught myself through the wonders of Google how to browse specific fields. I don't know the syntax for greater than. Ideally I would like something that says (and forgive my obvious lack of knowledge here)

BROWSE FIELDS fieldname FOR BETWEEN date(xx,xx,xx) AND DATE(xx,xx,xx)

Now I am 100% that is the wrong way to say it, but that's what I am trying to do. Any ideas?


r/DatabaseHelp • • Oct 16 '17

Oracle hr schema, subquery problem

1 Upvotes

Hi, I have been tasked with performing the following query: display the last_name, first_name, and department_id of all employees in the department that has the lowest average salary. Here is what I think the query should be: select department_id, last_name, first_name from employees where department_id in(select min(avg(salary)) from employees group by department_id); Please point me in the direction (Oracle documentation or elsewhere) to help me solve this problem. Thank you!