SQL column default value set using row wise operations

Is it possible to set a default value in a SQL column to be consisted of other columns? For example, in the table below is it possible to have the EndDate default to StartDate + NoOfDays? So when …

SQL one-to-many relationship: Should I see a “many” field in the table?

This is something basic which drives me crazy: If for example I have a table “team” and a table “player”. And the team can have multiple players in a one-to-many relation. Should …

Have I normalized this database to a 3NF level the right way? [closed]

I had a lecture at college recently about normalizing databases, but since we are online I can’t really ask a lot of questions, so here I am. Can someone tell me if I’m doing the conversion right, if …

How to structure limited voting system design

I have 3 types of tables. Categories, Candidates, Voters. To be describing the problem as short as possible, Candidates can belong to only 1 category. Voters can vote for each category and only one …

SQL DB structure for N items with M parameters varying over time

There’re the items: item_1 … item_N N is about a few hundreds. New items can be added sometimes. Each item has a set of parameters: parameter_1 … parameter_M M is about 20-30. These parameters …

SQL Database Design Union Data Type? [closed]

This may be a basic question, but I’m curious about what the most reasonable “preferred” way to design a database with a union type is. What I mean is consider a table Post which has only 1 piece …

How to prevent logical duplicates in a unary one to many SQL relationship table

In a non directional unary relationship what would be the best option to prevent logical duplicates? E.G. Main table ID — 1 2 Relational table ID1 ID2 ———– 1 2 2 1 Entry two …

Query for students passed or not passed in specific Subjects [closed]

I have a Table with Column Headings: ID Student_Name Roll_Number Subject1MarksObtained Subject1TotalMarks Subject2MarksObtained Subject2TotalMarks Subject3MarksObtained Subject3TotalMarks …

Building table of unique sets

What I’m trying to do is build a table of unique sets of rows. What is the aim? I’m building an app for a service provider (let’s say cable company for example). Every customer has a set of …

How to optimize a MySQL query which is taking 10 sec to fetch results

I have a MySQL database. I have a table in it which has around 200000 rows. I am querying through this table to fetch the latest data.Query select * from `db`.`Data` where floor = “floor_value”…